-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Initial set of classes for Incidents Batch Resolution
- Loading branch information
1 parent
efef1df
commit cc14f75
Showing
5 changed files
with
159 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
Sample/Helpdesk.Wolverine/Helpdesk.Api/Incidents/ResolutionBatch/IncidentsBatchResolution.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System.Collections.Immutable; | ||
|
||
namespace Helpdesk.Api.Incidents.ResolutionBatch; | ||
|
||
public record IncidentsBatchResolution( | ||
Guid Id, | ||
ImmutableDictionary<Guid, ResolutionStatus> Incidents, | ||
ResolutionStatus Status | ||
) | ||
{ | ||
public static IncidentsBatchResolution Create(IncidentsBatchResolutionInitiated initiated) => | ||
new( | ||
initiated.BatchId, | ||
initiated.Incidents.ToImmutableDictionary(ks => ks, vs => ResolutionStatus.Pending), | ||
ResolutionStatus.Pending | ||
); | ||
|
||
public IncidentsBatchResolution Apply(IncidentResolutionRecorded resolved) => | ||
this with { Incidents = Incidents.SetItem(resolved.IncidentId, ResolutionStatus.Resolved) }; | ||
|
||
public IncidentsBatchResolution Apply(IncidentResolutionFailureRecorded resolutionFailed) => | ||
this with { Incidents = Incidents.SetItem(resolutionFailed.IncidentId, ResolutionStatus.Failed) }; | ||
|
||
public IncidentsBatchResolution Apply(IncidentsBatchResolutionCompleted completed) => | ||
this with { Status = ResolutionStatus.Resolved }; | ||
|
||
public IncidentsBatchResolution Apply(IncidentsBatchResolutionFailed failed) => | ||
this with { Status = ResolutionStatus.Failed }; | ||
|
||
public IncidentsBatchResolution Apply(IncidentsBatchResolutionTimedOut timedOut) => | ||
this with { Status = ResolutionStatus.Failed }; | ||
} | ||
|
||
public enum ResolutionStatus | ||
{ | ||
Pending, | ||
Resolved, | ||
Failed | ||
} | ||
|
||
public record IncidentsBatchResolutionInitiated( | ||
Guid BatchId, | ||
List<Guid> Incidents, | ||
Guid InitiatedBy, | ||
DateTimeOffset InitiatedAt | ||
); | ||
|
||
public record IncidentResolutionRecorded( | ||
Guid IncidentId, | ||
Guid BatchId, | ||
DateTimeOffset ResolvedAt | ||
); | ||
|
||
public record IncidentResolutionFailureRecorded( | ||
Guid IncidentId, | ||
Guid BatchId, | ||
DateTimeOffset FailedAt | ||
); | ||
|
||
public record IncidentsBatchResolutionCompleted( | ||
Guid BatchId, | ||
List<Guid> Incidents, | ||
DateTimeOffset CompletedAt | ||
); | ||
|
||
public record IncidentsBatchResolutionFailed( | ||
Guid BatchId, | ||
Dictionary<Guid, ResolutionStatus> Incidents, | ||
DateTimeOffset FailedAt | ||
); | ||
|
||
public record IncidentsBatchResolutionTimedOut( | ||
Guid BatchId, | ||
Dictionary<Guid, ResolutionStatus> Incidents, | ||
DateTimeOffset TimedOutAt | ||
); |
32 changes: 32 additions & 0 deletions
32
...Helpdesk.Wolverine/Helpdesk.Api/Incidents/ResolutionBatch/IncidentsBatchResolutionSaga.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using JasperFx.Core; | ||
using Wolverine.Http; | ||
using Wolverine.Marten; | ||
|
||
namespace Helpdesk.Api.Incidents.ResolutionBatch; | ||
|
||
public static class IncidentsBatchResolutionSaga | ||
{ | ||
[WolverinePost("/api/agents/{agentId:guid}/incidents/resolve")] | ||
public static (CreationResponse, IStartStream) InitiateResolutionBatch( | ||
InitiateIncidentsBatchResolution command, | ||
DateTimeOffset now | ||
) | ||
{ | ||
var (incidents, agentId) = command; | ||
var batchId = CombGuidIdGeneration.NewGuid(); | ||
|
||
var @event = new IncidentsBatchResolutionInitiated(batchId, incidents, agentId, now); | ||
|
||
return ( | ||
new CreationResponse($"/api/incidents/resolution/{batchId}"), | ||
new StartStream<Incident>(batchId, @event) | ||
); | ||
} | ||
} | ||
|
||
public record InitiateIncidentsBatchResolution( | ||
List<Guid> Incidents, | ||
Guid AgentId | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters