Skip to content

Commit

Permalink
Renamed RegisteredRegisteredTimeouts to RegisteredTimeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
stidsborg committed Aug 5, 2024
1 parent fbceae9 commit 453cbf2
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ await functionStore.CreateFunction(
);
var eventSerializer = new EventSerializer();
var messagesWriter = new MessageWriter(functionId, functionStore, eventSerializer, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromSeconds(1),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -64,7 +64,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -102,7 +102,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -145,7 +145,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -187,7 +187,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -225,7 +225,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down Expand Up @@ -275,7 +275,7 @@ await functionStore.CreateFunction(
timestamp: DateTime.UtcNow.Ticks
);
var messagesWriter = new MessageWriter(functionId, functionStore, DefaultSerializer.Instance, scheduleReInvocation: (_, _) => Task.CompletedTask);
var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(functionId, functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
functionId,
defaultDelay: TimeSpan.FromMilliseconds(250),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected async Task ExistingActionCanBeDeletedFromControlPanel(Task<IFunctionSt
await messages.AppendMessage("Message");
var state = states.CreateOrGet<State>();
state.Value = "State";
await workflow.Messages.RegisteredRegisteredTimeouts.RegisterTimeout("Timeout", TimeSpan.FromDays(1));
await workflow.Messages.RegisteredTimeouts.RegisterTimeout("Timeout", TimeSpan.FromDays(1));
await state.Save();
}
);
Expand Down Expand Up @@ -96,7 +96,7 @@ async Task<string>(string _, Workflow workflow) =>
var state = states.CreateOrGet<State>();
state.Value = "State";
await state.Save();
await workflow.Messages.RegisteredRegisteredTimeouts.RegisterTimeout("Timeout", TimeSpan.FromDays(1));
await workflow.Messages.RegisteredTimeouts.RegisterTimeout("Timeout", TimeSpan.FromDays(1));
return "hello";
});

Expand Down Expand Up @@ -1508,7 +1508,7 @@ protected async Task ExistingTimeoutCanBeUpdatedForAction(Task<IFunctionStore> s
var actionRegistration = functionsRegistry.RegisterAction(
flowType,
Task (string param, Workflow workflow) =>
workflow.Messages.RegisteredRegisteredTimeouts.RegisterTimeout(
workflow.Messages.RegisteredTimeouts.RegisterTimeout(
"someTimeoutId", expiresAt: new DateTime(2100, 1,1, 1,1,1, DateTimeKind.Utc)
)
);
Expand Down Expand Up @@ -1550,7 +1550,7 @@ protected async Task ExistingTimeoutCanBeUpdatedForFunc(Task<IFunctionStore> sto
flowType,
async Task<string> (string param, Workflow workflow) =>
{
await workflow.Messages.RegisteredRegisteredTimeouts.RegisterTimeout(
await workflow.Messages.RegisteredTimeouts.RegisterTimeout(
"someTimeoutId", expiresAt: new DateTime(2100, 1, 1, 1, 1, 1, DateTimeKind.Utc)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected async Task ExpiredTimeoutIsAddedToMessages(Task<IFunctionStore> storeT
{
var messages = workflow.Messages;
var timeoutTask = messages.OfType<TimeoutEvent>().First();
await messages.RegisteredRegisteredTimeouts.RegisterTimeout("test", expiresIn: TimeSpan.FromMilliseconds(500));
await messages.RegisteredTimeouts.RegisterTimeout("test", expiresIn: TimeSpan.FromMilliseconds(500));
timeoutTask.IsCompleted.ShouldBeFalse();
var timeout = await timeoutTask;
timeout.TimeoutId.ShouldBe("test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected async Task RegisteredTimeoutIsReturnedFromTimeoutProvider(Task<ITimeou
var store = await storeTask;
var functionId = TestFlowId.Create();

var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, store);
var timeoutProvider = new RegisteredTimeouts(functionId, store);

await timeoutProvider.RegisterTimeout("timeoutId1", expiresIn: TimeSpan.FromHours(1));
await timeoutProvider.RegisterTimeout("timeoutId2", expiresIn: TimeSpan.FromHours(2));
Expand All @@ -126,9 +126,9 @@ protected async Task RegisteredTimeoutIsReturnedFromTimeoutProviderForFunctionId
var store = await storeTask;
var functionId = TestFlowId.Create();

var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, store);
var timeoutProvider = new RegisteredTimeouts(functionId, store);

var otherInstanceTimeoutProvider = new RegisteredRegisteredTimeouts(
var otherInstanceTimeoutProvider = new RegisteredTimeouts(
new FlowId(functionId.Type, functionId.Instance.Value + "2"),
store
);
Expand All @@ -152,7 +152,7 @@ protected async Task TimeoutIsNotRegisteredAgainWhenProviderAlreadyContainsTimeo
var store = new TimeoutStoreDecorator(await storeTask, () => upsertCount++);
var functionId = TestFlowId.Create();

var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, store);
var timeoutProvider = new RegisteredTimeouts(functionId, store);

await timeoutProvider.RegisterTimeout("timeoutId1", expiresIn: TimeSpan.FromHours(1));
upsertCount.ShouldBe(1);
Expand All @@ -172,7 +172,7 @@ protected async Task CancellingNonExistingTimeoutDoesNotResultInIO(Task<ITimeout
var store = new TimeoutStoreDecorator(await storeTask, removeTimeoutCallback: () => removeCount++);
var functionId = TestFlowId.Create();

var timeoutProvider = new RegisteredRegisteredTimeouts(functionId, store);
var timeoutProvider = new RegisteredTimeouts(functionId, store);

var pendingTimeouts = await timeoutProvider.PendingTimeouts();
pendingTimeouts.ShouldBeEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ await _functionStore.BulkScheduleFunctions(
public Messages CreateMessages(FlowId flowId, ScheduleReInvocation scheduleReInvocation, Func<bool> isWorkflowRunning)
{
var messageWriter = new MessageWriter(flowId, _functionStore, Serializer, scheduleReInvocation);
var timeoutProvider = new RegisteredRegisteredTimeouts(flowId, _functionStore.TimeoutStore);
var timeoutProvider = new RegisteredTimeouts(flowId, _functionStore.TimeoutStore);
var messagesPullerAndEmitter = new MessagesPullerAndEmitter(
flowId,
defaultDelay: _settings.MessagesPullFrequency,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public interface IRegisteredTimeouts
Task<IReadOnlyList<RegisteredTimeout>> PendingTimeouts();
}

public class RegisteredRegisteredTimeouts(FlowId flowId, ITimeoutStore timeoutStore) : IRegisteredTimeouts
public class RegisteredTimeouts(FlowId flowId, ITimeoutStore timeoutStore) : IRegisteredTimeouts
{
private Dictionary<TimeoutId, RegisteredTimeout>? _localTimeouts;
private readonly object _sync = new();
Expand Down
6 changes: 3 additions & 3 deletions Core/Cleipnir.ResilientFunctions/Messaging/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ namespace Cleipnir.ResilientFunctions.Messaging;

public class Messages : IReactiveChain<object>
{
public RegisteredRegisteredTimeouts RegisteredRegisteredTimeouts { get; }
public RegisteredTimeouts RegisteredTimeouts { get; }
public IReactiveChain<object> Source => _messagePullerAndEmitter.Source;

private readonly MessageWriter _messageWriter;
private readonly MessagesPullerAndEmitter _messagePullerAndEmitter;

public Messages(
MessageWriter messageWriter,
RegisteredRegisteredTimeouts registeredRegisteredTimeouts,
RegisteredTimeouts registeredTimeouts,
MessagesPullerAndEmitter messagePullerAndEmitter
)
{
_messageWriter = messageWriter;
RegisteredRegisteredTimeouts = registeredRegisteredTimeouts;
RegisteredTimeouts = registeredTimeouts;
_messagePullerAndEmitter = messagePullerAndEmitter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ public static class TimeoutExtensions
public static async Task RegisterTimeoutEvent(this Messages messages, string timeoutId, DateTime expiresAt)
{
if (!DoesMessagesAlreadyContainTimeoutEvent(messages, timeoutId))
await messages.RegisteredRegisteredTimeouts.RegisterTimeout(timeoutId, expiresAt);
await messages.RegisteredTimeouts.RegisterTimeout(timeoutId, expiresAt);
}

public static async Task RegisterTimeoutEvent(this Messages messages, string timeoutId, TimeSpan expiresIn)
{
if (!DoesMessagesAlreadyContainTimeoutEvent(messages, timeoutId))
await messages.RegisteredRegisteredTimeouts.RegisterTimeout(timeoutId, expiresIn);
await messages.RegisteredTimeouts.RegisterTimeout(timeoutId, expiresIn);
}

public static async Task CancelTimeoutEvent(this Messages messages, string timeoutId)
{
if (!DoesMessagesAlreadyContainTimeoutEvent(messages, timeoutId))
await messages.RegisteredRegisteredTimeouts.CancelTimeout(timeoutId);
await messages.RegisteredTimeouts.CancelTimeout(timeoutId);
}

private static bool DoesMessagesAlreadyContainTimeoutEvent(Messages messages, string timeoutId)
Expand Down

0 comments on commit 453cbf2

Please sign in to comment.