Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove SetOptions method from builder #178

Merged
merged 7 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ConductorSharp.Engine.Util;
using MediatR;
using System.Text;
using ConductorSharp.Engine.Builders.Metadata;

namespace ConductorSharp.ApiEnabled.Handlers;

Expand Down
4 changes: 2 additions & 2 deletions examples/ConductorSharp.ApiEnabled/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
var configuration = builder.Configuration;

// Add services to the container.
builder.Services
.AddControllers()
builder
.Services.AddControllers()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
Expand Down
3 changes: 2 additions & 1 deletion examples/ConductorSharp.Definitions/Generated/Task.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ConductorSharp.Engine.Model;
using ConductorSharp.Engine.Builders.Metadata;
using ConductorSharp.Engine.Model;
using ConductorSharp.Engine.Util;
using MediatR;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ConductorSharp.Engine.Builders;
using ConductorSharp.Engine.Builders.Metadata;
using ConductorSharp.Engine.Model;
using ConductorSharp.Patterns.Builders;
using ConductorSharp.Patterns.Model;
Expand All @@ -14,6 +15,7 @@ public class CSharpLambdaWorkflowInput : WorkflowInput<CSharpLambdaWorkflowOutpu

public class CSharpLambdaWorkflowOutput : WorkflowOutput { }

[WorkflowMetadata(OwnerEmail = "[email protected]")]
public class CSharpLambdaWorkflow : Workflow<CSharpLambdaWorkflow, CSharpLambdaWorkflowInput, CSharpLambdaWorkflowOutput>
{
public class LambdaTaskInput : IRequest<LambdaTaskOutput>
Expand Down Expand Up @@ -81,8 +83,6 @@ public override void BuildDefinition()
}
);
#pragma warning restore CS0618 // Type or member is obsolete

_builder.SetOptions(options => options.OwnerEmail = "[email protected]");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ConductorSharp.Engine.Builders;
using ConductorSharp.Engine.Builders.Metadata;
using ConductorSharp.Engine.Util;
using ConductorSharp.Patterns.Tasks;
using Newtonsoft.Json;
Expand All @@ -14,18 +15,19 @@ public class HandleNotificationFailureInput : WorkflowInput<HandleNotificationFa
public class HandleNotificationFailureOutput : WorkflowOutput { }

[OriginalName("NOTIFICATION_handle_failure")]
[WorkflowMetadata(OwnerEmail = "[email protected]")]
public class HandleNotificationFailure : Workflow<HandleNotificationFailure, HandleNotificationFailureInput, HandleNotificationFailureOutput>
{
public HandleNotificationFailure(
WorkflowDefinitionBuilder<HandleNotificationFailure, HandleNotificationFailureInput, HandleNotificationFailureOutput> builder
) : base(builder) { }
)
: base(builder) { }

public ReadWorkflowTasks ReadExecutedTasks { get; set; }

public override void BuildDefinition()
{
_builder.AddTask(a => a.ReadExecutedTasks, b => new() { TaskNames = "dynamic_handler", WorkflowId = b.WorkflowInput.WorkflowId });
_builder.SetOptions(options => options.OwnerEmail = "[email protected]");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ConductorSharp.Definitions.Generated;
using ConductorSharp.Engine.Builders;
using ConductorSharp.Engine.Builders.Metadata;
using ConductorSharp.Engine.Model;
using ConductorSharp.Engine.Util;
using ConductorSharp.Patterns.Tasks;
Expand All @@ -25,11 +26,13 @@ public class ExpectedDynamicInput : CustomerGetV1Input, IRequest<ExpectedDynamic
public class ExpectedDynamicOutput : CustomerGetV1Output { }

[OriginalName("NOTIFICATION_send_to_customer")]
[WorkflowMetadata(OwnerEmail = "[email protected]", FailureWorkflow = typeof(HandleNotificationFailure))]
public class SendCustomerNotification : Workflow<SendCustomerNotification, SendCustomerNotificationInput, SendCustomerNotificationOutput>
{
public SendCustomerNotification(
WorkflowDefinitionBuilder<SendCustomerNotification, SendCustomerNotificationInput, SendCustomerNotificationOutput> builder
) : base(builder) { }
)
: base(builder) { }

public EmailPrepareV1 PrepareEmail { get; set; }
public DynamicTaskModel<ExpectedDynamicInput, ExpectedDynamicOutput> DynamicHandler { get; set; }
Expand Down Expand Up @@ -60,13 +63,6 @@ public override void BuildDefinition()
Constant = 500
}
);

_builder.SetOptions(options =>
{
options.Version = 1;
options.FailureWorkflow = typeof(HandleNotificationFailure);
options.OwnerEmail = "[email protected]";
});
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ConductorSharp.Engine.Util;
using MediatR;
using System.ComponentModel.DataAnnotations;
using ConductorSharp.Engine.Builders.Metadata;

namespace ConductorSharp.NoApi.Handlers;

Expand Down
2 changes: 1 addition & 1 deletion src/ConductorSharp.Client/ApiException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ApiException(
string responseData,
IReadOnlyDictionary<string, IEnumerable<string>> headers,
JsonException exception
) : Exception(message, exception)
) : Exception(message, exception)
{
public ConductorErrorResponse? Errors { get; private set; } = JsonConvert.DeserializeObject<ConductorErrorResponse>(responseData);
public int StatusCode { get; private set; } = statusCode;
Expand Down
27 changes: 14 additions & 13 deletions src/ConductorSharp.Client/Service/AdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ namespace ConductorSharp.Client.Service
{
public class AdminService(ConductorClient client) : IAdminService
{
public async Task<string> QueueRunningWorkflowsForSweepAsync(string workflowId, CancellationToken cancellationToken = default)
=> await client.RequeueSweepAsync(workflowId, cancellationToken);
public async Task<string> QueueRunningWorkflowsForSweepAsync(string workflowId, CancellationToken cancellationToken = default) =>
await client.RequeueSweepAsync(workflowId, cancellationToken);

public async Task<string> VerifyAndRepairWorkflowConsistencyAsync(string workflowId,
CancellationToken cancellationToken = default)
=> await client.VerifyAndRepairWorkflowConsistencyAsync(workflowId, cancellationToken);
public async Task<string> VerifyAndRepairWorkflowConsistencyAsync(string workflowId, CancellationToken cancellationToken = default) =>
await client.VerifyAndRepairWorkflowConsistencyAsync(workflowId, cancellationToken);

public async Task<ICollection<Generated.Task>> ListPendingTasksAsync(string taskType, int? start, int? count,
CancellationToken cancellationToken = default)
=> await client.ViewAsync(taskType, start, count, cancellationToken);
public async Task<ICollection<Generated.Task>> ListPendingTasksAsync(
string taskType,
int? start,
int? count,
CancellationToken cancellationToken = default
) => await client.ViewAsync(taskType, start, count, cancellationToken);

public async Task<IDictionary<string, object>> GetEventQueueMapAsync(bool? verbose,
CancellationToken cancellationToken = default)
=> await client.GetEventQueuesAsync(verbose, cancellationToken);
public async Task<IDictionary<string, object>> GetEventQueueMapAsync(bool? verbose, CancellationToken cancellationToken = default) =>
await client.GetEventQueuesAsync(verbose, cancellationToken);

public async Task<IDictionary<string, object>> GetConfigMapAsync(CancellationToken cancellationToken = default)
=> await client.GetAllConfigAsync(cancellationToken);
public async Task<IDictionary<string, object>> GetConfigMapAsync(CancellationToken cancellationToken = default) =>
await client.GetAllConfigAsync(cancellationToken);
}
}
25 changes: 13 additions & 12 deletions src/ConductorSharp.Client/Service/EventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ namespace ConductorSharp.Client.Service
{
public class EventService(ConductorClient client) : IEventService
{
public async Task<ICollection<EventHandler>> ListAsync(CancellationToken cancellationToken = default)
=> await client.GetEventHandlersAsync(cancellationToken);
public async Task<ICollection<EventHandler>> ListAsync(CancellationToken cancellationToken = default) =>
await client.GetEventHandlersAsync(cancellationToken);

public async Task UpdateAsync(EventHandler eventHandler, CancellationToken cancellationToken = default)
=> await client.UpdateEventHandlerAsync(eventHandler, cancellationToken);
public async Task UpdateAsync(EventHandler eventHandler, CancellationToken cancellationToken = default) =>
await client.UpdateEventHandlerAsync(eventHandler, cancellationToken);

public async Task AddAsync(EventHandler eventHandler, CancellationToken cancellationToken = default)
=> await client.AddEventHandlerAsync(eventHandler, cancellationToken);
public async Task AddAsync(EventHandler eventHandler, CancellationToken cancellationToken = default) =>
await client.AddEventHandlerAsync(eventHandler, cancellationToken);

public async Task<ICollection<EventHandler>> ListForEventAsync(string @event, bool? activeOnly = null,
CancellationToken cancellationToken = default)
=> await client.GetEventHandlersForEventAsync(@event, activeOnly, cancellationToken);

public async Task RemoveEventHandlerStatusAsync(string name, CancellationToken cancellationToken = default)
=> await client.RemoveEventHandlerStatusAsync(name, cancellationToken);
public async Task<ICollection<EventHandler>> ListForEventAsync(
string @event,
bool? activeOnly = null,
CancellationToken cancellationToken = default
) => await client.GetEventHandlersForEventAsync(@event, activeOnly, cancellationToken);

public async Task RemoveEventHandlerStatusAsync(string name, CancellationToken cancellationToken = default) =>
await client.RemoveEventHandlerStatusAsync(name, cancellationToken);
}
}
5 changes: 2 additions & 3 deletions src/ConductorSharp.Client/Service/ExternalPayloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ namespace ConductorSharp.Client.Service
{
public class ExternalPayloadService(ConductorClient client) : IExternalPayloadService
{
public async Task<FileResponse> GetExternalStorageDataAsync(string externalPayloadPath,
CancellationToken cancellationToken = default)
=> await client.GetExternalStorageDataAsync(externalPayloadPath, cancellationToken);
public async Task<FileResponse> GetExternalStorageDataAsync(string externalPayloadPath, CancellationToken cancellationToken = default) =>
await client.GetExternalStorageDataAsync(externalPayloadPath, cancellationToken);
}
}
4 changes: 2 additions & 2 deletions src/ConductorSharp.Client/Service/IExternalPayloadService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ConductorSharp.Client.Generated;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using ConductorSharp.Client.Generated;

namespace ConductorSharp.Client.Service
{
Expand Down
4 changes: 2 additions & 2 deletions src/ConductorSharp.Client/Service/IHealthService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using ConductorSharp.Client.Generated;
using System.Threading;
using System.Threading;
using System.Threading.Tasks;
using ConductorSharp.Client.Generated;

namespace ConductorSharp.Client.Service
{
Expand Down
4 changes: 2 additions & 2 deletions src/ConductorSharp.Client/Service/IQueueAdminService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using ConductorSharp.Client.Generated;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using ConductorSharp.Client.Generated;

namespace ConductorSharp.Client.Service
{
Expand Down
55 changes: 26 additions & 29 deletions src/ConductorSharp.Client/Service/MetadataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,43 @@ namespace ConductorSharp.Client.Service
{
public class MetadataService(ConductorClient client) : IMetadataService
{
public async Task<ICollection<WorkflowDef>> ListWorkflowsAsync(CancellationToken cancellationToken = default)
=> await client.GetAllAsync(cancellationToken);
public async Task<ICollection<WorkflowDef>> ListWorkflowsAsync(CancellationToken cancellationToken = default) =>
await client.GetAllAsync(cancellationToken);

public async Task<BulkResponse> UpdateWorkflowsAsync(IEnumerable<WorkflowDef> workflows, CancellationToken cancellationToken = default)
=> await client.UpdateAsync(workflows, cancellationToken);
public async Task<BulkResponse> UpdateWorkflowsAsync(IEnumerable<WorkflowDef> workflows, CancellationToken cancellationToken = default) =>
await client.UpdateAsync(workflows, cancellationToken);

public async Task AddWorkflowAsync(WorkflowDef workflowDef, CancellationToken cancellationToken = default)
=> await client.CreateAsync(workflowDef, cancellationToken);
public async Task AddWorkflowAsync(WorkflowDef workflowDef, CancellationToken cancellationToken = default) =>
await client.CreateAsync(workflowDef, cancellationToken);

public async Task<ICollection<TaskDef>> ListTasksAsync(CancellationToken cancellationToken = default)
=> await client.GetTaskDefsAsync(cancellationToken);
public async Task<ICollection<TaskDef>> ListTasksAsync(CancellationToken cancellationToken = default) =>
await client.GetTaskDefsAsync(cancellationToken);

public async Task AddTaskAsync(TaskDef taskDef, CancellationToken cancellationToken = default)
=> await client.RegisterTaskDefAsync(taskDef, cancellationToken);
public async Task AddTaskAsync(TaskDef taskDef, CancellationToken cancellationToken = default) =>
await client.RegisterTaskDefAsync(taskDef, cancellationToken);

public async Task AddTasksAsync(IEnumerable<TaskDef> taskDefs, CancellationToken cancellationToken = default)
=> await client.RegisterTaskDef_1Async(taskDefs, cancellationToken);
public async Task AddTasksAsync(IEnumerable<TaskDef> taskDefs, CancellationToken cancellationToken = default) =>
await client.RegisterTaskDef_1Async(taskDefs, cancellationToken);

public async Task ValidateWorkflowAsync(WorkflowDef workflowDef, CancellationToken cancellationToken = default)
=> await client.ValidateAsync(workflowDef, cancellationToken);
public async Task ValidateWorkflowAsync(WorkflowDef workflowDef, CancellationToken cancellationToken = default) =>
await client.ValidateAsync(workflowDef, cancellationToken);

public async Task<WorkflowDef> GetWorkflowAsync(string name, int? version = null,
CancellationToken cancellationToken = default)
=> await client.GetAsync(name, version, cancellationToken);
public async Task<WorkflowDef> GetWorkflowAsync(string name, int? version = null, CancellationToken cancellationToken = default) =>
await client.GetAsync(name, version, cancellationToken);

public async Task<IDictionary<string, object>> GetWorkflowNamesAndVersionsAsync(
CancellationToken cancellationToken = default)
=> await client.GetWorkflowNamesAndVersionsAsync(cancellationToken);
public async Task<IDictionary<string, object>> GetWorkflowNamesAndVersionsAsync(CancellationToken cancellationToken = default) =>
await client.GetWorkflowNamesAndVersionsAsync(cancellationToken);

public async Task<ICollection<WorkflowDef>> GetAllWorkflowsWithLatestVersionsAsync(
CancellationToken cancellationToken = default)
=> await client.GetAllWorkflowsWithLatestVersionsAsync(cancellationToken);
public async Task<ICollection<WorkflowDef>> GetAllWorkflowsWithLatestVersionsAsync(CancellationToken cancellationToken = default) =>
await client.GetAllWorkflowsWithLatestVersionsAsync(cancellationToken);

public async Task<TaskDef> GetTaskAsync(string taskType, CancellationToken cancellationToken = default)
=> await client.GetTaskDefAsync(taskType, cancellationToken);
public async Task<TaskDef> GetTaskAsync(string taskType, CancellationToken cancellationToken = default) =>
await client.GetTaskDefAsync(taskType, cancellationToken);

public async Task DeleteTaskAsync(string taskType, CancellationToken cancellationToken = default)
=> await client.UnregisterTaskDefAsync(taskType, cancellationToken);
public async Task DeleteTaskAsync(string taskType, CancellationToken cancellationToken = default) =>
await client.UnregisterTaskDefAsync(taskType, cancellationToken);

public async Task DeleteWorkflowAsync(string name, int version, CancellationToken cancellationToken = default)
=> await client.UnregisterWorkflowDefAsync(name, version, cancellationToken);
public async Task DeleteWorkflowAsync(string name, int version, CancellationToken cancellationToken = default) =>
await client.UnregisterWorkflowDefAsync(name, version, cancellationToken);
}
}
30 changes: 19 additions & 11 deletions src/ConductorSharp.Client/Service/QueueAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ namespace ConductorSharp.Client.Service;

public class QueueAdminService(ConductorClient client) : IQueueAdminService
{
public async Task MarkWaitTaskCompletedAsync(string workflowId, string taskRefName, Status status,
IDictionary<string, object> output, CancellationToken cancellationToken = default)
=> await client.Update_1Async(workflowId, taskRefName, status, output, cancellationToken);
public async Task MarkWaitTaskCompletedAsync(
string workflowId,
string taskRefName,
Status status,
IDictionary<string, object> output,
CancellationToken cancellationToken = default
) => await client.Update_1Async(workflowId, taskRefName, status, output, cancellationToken);

public async Task MarkWaitTaskCompletedAsync(string workflowId, string taskId, Status2 status,
IDictionary<string, object> output, CancellationToken cancellationToken = default)
=> await client.UpdateByTaskIdAsync(workflowId, taskId, status, output, cancellationToken);
public async Task MarkWaitTaskCompletedAsync(
string workflowId,
string taskId,
Status2 status,
IDictionary<string, object> output,
CancellationToken cancellationToken = default
) => await client.UpdateByTaskIdAsync(workflowId, taskId, status, output, cancellationToken);

public async Task<IDictionary<string, long>> GetQueueLengthAsync(CancellationToken cancellationToken = default)
=> await client.Size_1Async(cancellationToken);
public async Task<IDictionary<string, long>> GetQueueLengthAsync(CancellationToken cancellationToken = default) =>
await client.Size_1Async(cancellationToken);

public async Task<IDictionary<string, string>> GetQueueNamesAsync(CancellationToken cancellationToken = default)
=> await client.NamesAsync(cancellationToken);
}
public async Task<IDictionary<string, string>> GetQueueNamesAsync(CancellationToken cancellationToken = default) =>
await client.NamesAsync(cancellationToken);
}
Loading