Skip to content

Commit a768a68

Browse files
Added "command in error" classifier
1 parent db06941 commit a768a68

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

examples/bank-account/RetailBank.AzureFunctionApp/Transfer/Functions/TransferCommands.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ namespace RetailBank.AzureFunctionApp.Transfer.Functions
77
public class TransferCommands
88
{
99

10+
//Transfer money
1011

12+
//Cancel in-progress transfer
1113

1214
}
1315
}

src/EventSourcingOnAzureFunctions.Common/CQRS/CommandHandler/Classifications/Completed.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ namespace EventSourcingOnAzureFunctions.Common.CQRS.CommandHandler.Classificatio
1111
/// A classification to denote that a command execution has completed
1212
/// </summary>
1313
[ClassificationName("Command Completed") ]
14-
public class Completed
14+
public sealed class Completed
1515
: ClassificationBase,
1616
IClassifyEventType<Completed>
1717
{
1818

1919

2020
public ClassificationResponse.ClassificationResults ClassifyEventInstance(Completed eventInstance)
2121
{
22-
return ClassificationResponse.ClassificationResults.Include;
22+
if (eventInstance != null)
23+
{
24+
return ClassificationResponse.ClassificationResults.Include;
25+
}
26+
return ClassificationResponse.ClassificationResults.Unchanged;
2327
}
2428

2529
public override void SetParameter(string parameterName, object parameterValue)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using EventSourcingOnAzureFunctions.Common.CQRS.CommandHandler.Events;
5+
using EventSourcingOnAzureFunctions.Common.EventSourcing;
6+
using EventSourcingOnAzureFunctions.Common.EventSourcing.Interfaces;
7+
8+
namespace EventSourcingOnAzureFunctions.Common.CQRS.CommandHandler.Classifications
9+
{
10+
/// <summary>
11+
/// A classification to denote that a command execution has had a fatal error
12+
/// </summary>
13+
[ClassificationName("Command In Error")]
14+
public sealed class InError
15+
: ClassificationBase,
16+
IClassifyEventType<FatalErrorOccured>
17+
{
18+
public ClassificationResponse.ClassificationResults ClassifyEventInstance(FatalErrorOccured eventInstance)
19+
{
20+
if (eventInstance != null)
21+
{
22+
return ClassificationResponse.ClassificationResults.Include;
23+
}
24+
return ClassificationResponse.ClassificationResults.Unchanged;
25+
}
26+
27+
public override void SetParameter(string parameterName, object parameterValue)
28+
{
29+
// This classifier has no parameters
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)