Skip to content

Commit 062cbdb

Browse files
authored
Remove Postman wrapper, call MessageWriters directly (#139)
Postman was a two-method passthrough over MessageWriters with no behaviour of its own. Inline the calls in the registration classes and drop the type.
1 parent ee98fba commit 062cbdb

6 files changed

Lines changed: 11 additions & 43 deletions

File tree

Core/Cleipnir.ResilientFunctions/ActionRegistration.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ public ActionRegistration(
2626
Invoker<TParam, Unit> invoker,
2727
ControlPanelFactory<TParam> controlPanelFactory,
2828
MessageWriters messageWriters,
29-
Postman postman,
3029
UtcNow utcNow
31-
) : base(storedType, postman, functionStore, utcNow)
30+
) : base(storedType, functionStore, utcNow)
3231
{
3332
Type = flowType;
3433
_invoker = invoker;
@@ -59,8 +58,8 @@ public async Task SendMessage<T>(
5958
FlowInstance flowInstance,
6059
T message,
6160
string? idempotencyKey = null
62-
) where T : class => await Postman.SendMessage(StoredId.Create(StoredType, flowInstance.Value), message, idempotencyKey);
61+
) where T : class => await MessageWriters.For(flowInstance).AppendMessage(message, idempotencyKey);
6362

6463
public async Task SendMessages(IReadOnlyList<BatchedMessage> messages)
65-
=> await Postman.SendMessages(messages);
64+
=> await MessageWriters.AppendMessages(messages);
6665
}

Core/Cleipnir.ResilientFunctions/BaseRegistration.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,22 @@
33
using System.Threading.Tasks;
44
using Cleipnir.ResilientFunctions.CoreRuntime;
55
using Cleipnir.ResilientFunctions.Domain;
6-
using Cleipnir.ResilientFunctions.Messaging;
76
using Cleipnir.ResilientFunctions.Storage;
87

98
namespace Cleipnir.ResilientFunctions;
109

1110
public abstract class BaseRegistration
1211
{
1312
private readonly IFunctionStore _functionStore;
14-
protected Postman Postman { get; }
1513
public StoredType StoredType { get; }
1614
protected UtcNow UtcNow { get; }
1715

18-
protected BaseRegistration(StoredType storedType, Postman postman, IFunctionStore functionStore, UtcNow utcNow)
16+
protected BaseRegistration(StoredType storedType, IFunctionStore functionStore, UtcNow utcNow)
1917
{
2018
_functionStore = functionStore;
2119
StoredType = storedType;
22-
Postman = postman;
2320
UtcNow = utcNow;
24-
}
21+
}
2522

2623
public StoredId MapToStoredId(FlowInstance instance) => StoredId.Create(StoredType, instance.Value);
2724

Core/Cleipnir.ResilientFunctions/FuncRegistration.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ public FuncRegistration(
2525
Invoker<TParam, TReturn> invoker,
2626
ControlPanelFactory<TParam, TReturn> controlPanelFactory,
2727
MessageWriters messageWriters,
28-
Postman postman,
2928
UtcNow utcNow
30-
) : base(storedType, postman, functionStore, utcNow)
29+
) : base(storedType, functionStore, utcNow)
3130
{
3231
Type = flowType;
3332
_invoker = invoker;
@@ -59,8 +58,8 @@ public async Task SendMessage<T>(
5958
FlowInstance flowInstance,
6059
T message,
6160
string? idempotencyKey = null
62-
) where T : class => await Postman.SendMessage(StoredId.Create(StoredType, flowInstance.Value), message, idempotencyKey);
61+
) where T : class => await MessageWriters.For(flowInstance).AppendMessage(message, idempotencyKey);
6362

6463
public async Task SendMessages(IReadOnlyList<BatchedMessage> messages)
65-
=> await Postman.SendMessages(messages);
64+
=> await MessageWriters.AppendMessages(messages);
6665
}

Core/Cleipnir.ResilientFunctions/FunctionsRegistry.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,13 @@ public FuncRegistration<TParam, TReturn> RegisterFunc<TParam, TReturn>(
258258
serializer
259259
);
260260

261-
var postman = new Postman(messageWriters);
262-
263261
var registration = new FuncRegistration<TParam, TReturn>(
264262
flowType,
265263
storedType,
266264
_functionStore,
267265
invoker,
268266
controlPanels,
269267
messageWriters,
270-
postman,
271268
_settings.UtcNow
272269
);
273270
_functions[flowType] = registration;
@@ -343,16 +340,13 @@ private ParamlessRegistration RegisterParamless(
343340
serializer
344341
);
345342

346-
var postman = new Postman(messageWriters);
347-
348343
var registration = new ParamlessRegistration(
349344
flowType,
350345
storedType,
351346
_functionStore,
352347
invoker,
353348
controlPanels,
354349
messageWriters,
355-
postman,
356350
_settings.UtcNow
357351
);
358352
_functions[flowType] = registration;
@@ -427,16 +421,13 @@ public ActionRegistration<TParam> RegisterAction<TParam>(
427421
_functionStore,
428422
serializer
429423
);
430-
var postman = new Postman(messageWriters);
431-
432424
var registration = new ActionRegistration<TParam>(
433425
flowType,
434426
storedType,
435427
_functionStore,
436428
rActionInvoker,
437429
controlPanels,
438430
messageWriters,
439-
postman,
440431
_settings.UtcNow
441432
);
442433
_functions[flowType] = registration;

Core/Cleipnir.ResilientFunctions/Messaging/Postman.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

Core/Cleipnir.ResilientFunctions/ParamlessRegistration.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ public ParamlessRegistration(
2727
Invoker<Unit, Unit> invoker,
2828
ControlPanelFactory controlPanelFactory,
2929
MessageWriters messageWriters,
30-
Postman postman,
3130
UtcNow utcNow
32-
) : base(storedType, postman, functionStore, utcNow)
31+
) : base(storedType, functionStore, utcNow)
3332
{
3433
Type = flowType;
3534
_invoker = invoker;
@@ -70,9 +69,9 @@ public async Task SendMessage<T>(
7069
await Schedule(flowInstance);
7170
}
7271

73-
await Postman.SendMessage(StoredId.Create(StoredType, flowInstance.Value), message, idempotencyKey);
72+
await MessageWriters.For(flowInstance).AppendMessage(message, idempotencyKey);
7473
}
7574

7675
public async Task SendMessages(IReadOnlyList<BatchedMessage> messages)
77-
=> await Postman.SendMessages(messages);
76+
=> await MessageWriters.AppendMessages(messages);
7877
}

0 commit comments

Comments
 (0)