Skip to content

Commit

Permalink
Add options for IncludeDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
jviau committed May 12, 2020
1 parent f6977a9 commit ef5e3fb
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using DurableTask.DependencyInjection;
using DurableTask.Hosting.Options;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Expand Down
37 changes: 37 additions & 0 deletions src/DurableTask.Hosting/src/Options/IncludeDetails.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright (c) Jacob Viau. All rights reserved.
// Licensed under the APACHE 2.0. See LICENSE file in the project root for full license information.

using System;
using DurableTask.Core;

namespace DurableTask.Hosting.Options
{
/// <summary>
/// The flags for when to include error details.
/// </summary>
[Flags]
public enum IncludeDetails
{
/// <summary>
/// Do not include error details
/// </summary>
None = 0,

/// <summary>
/// Enabled for activities.
/// <see cref="TaskActivityDispatcher.IncludeDetails"/>.
/// </summary>
Activities = 1 << 0,

/// <summary>
/// Enabled for orchestrations.
/// <see cref="TaskOrchestrationDispatcher.IncludeDetails"/>.
/// </summary>
Orchestrations = 1 << 1,

/// <summary>
/// Enabled for all.
/// </summary>
All = Activities | Orchestrations,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using DurableTask.Core;

namespace DurableTask.Hosting
namespace DurableTask.Hosting.Options
{
/// <summary>
/// The options for the task hub host.
Expand All @@ -15,5 +15,11 @@ public class TaskHubOptions
/// do not exist on startup. <see cref="IOrchestrationService.CreateIfNotExistsAsync"/>.
/// </summary>
public bool CreateIfNotExists { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to include error details in task failures or not.
/// <see cref="TaskActivityDispatcher.IncludeDetails"/> and <see cref="TaskOrchestrationDispatcher.IncludeDetails"/>.
/// </summary>
public IncludeDetails IncludeDetails { get; set; }
}
}
7 changes: 6 additions & 1 deletion src/DurableTask.Hosting/src/TaskHubBackgroundService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
using DurableTask.Core;
using DurableTask.Hosting.Options;
using DurableTask.Hosting.Properties;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -36,17 +37,21 @@ public TaskHubBackgroundService(
_options = Check.NotNull(options, nameof(options));
}

private TaskHubOptions Options => _options.Value;

/// <inheritdoc />
public async Task StartAsync(CancellationToken cancellationToken)
{
_logger.LogDebug(Strings.TaskHubWorkerStarting);

if (_options.Value.CreateIfNotExists)
if (Options.CreateIfNotExists)
{
await _worker.orchestrationService.CreateIfNotExistsAsync().ConfigureAwait(false);
}

await _worker.StartAsync().ConfigureAwait(false);
_worker.TaskActivityDispatcher.IncludeDetails = Options.IncludeDetails.HasFlag(IncludeDetails.Activities);
_worker.TaskOrchestrationDispatcher.IncludeDetails = Options.IncludeDetails.HasFlag(IncludeDetails.Orchestrations);
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading;
using System.Threading.Tasks;
using DurableTask.Core;
using DurableTask.Hosting.Options;
using FluentAssertions;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down

0 comments on commit ef5e3fb

Please sign in to comment.