-
Notifications
You must be signed in to change notification settings - Fork 260
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
Add support to scheduler message #3487
Draft
lillo42
wants to merge
20
commits into
BrighterCommand:master
Choose a base branch
from
lillo42:message-scheduler-v1
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
44af426
Init Message Scheduler V1
lillo42 b8d365b
Init support to scheduler messages
lillo42 6ddfa0c
Improve scheduler
lillo42 8fa4a58
Improve scheduler
lillo42 0c54163
Add ADR
lillo42 42b904c
rollback unnecessary changes
lillo42 69d2871
Merge branch 'master' into message-scheduler-v1
lillo42 b377821
Improve Scheduler support
lillo42 3cfa7f3
Improve scheduler messages
lillo42 cd0ec7f
Fixes unit tests
lillo42 aff9240
Add Unit test
lillo42 172f9c2
Merge branch 'master' into message-scheduler-v1
lillo42 0bed01e
Remove Hangfire and add Quartz
lillo42 a6abc68
Fixes unit test
lillo42 c266d09
Quartz Add support to .NET Standard & .NET 9.0
lillo42 6340079
Add AWS Scheduler
lillo42 dad21ca
Add Missing file
lillo42 834cf17
Add AWS Scheduler
lillo42 b908bb9
Add Scheduler Samples
lillo42 d83b7b9
Merge branch 'master' into message-scheduler-v1
lillo42 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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,89 @@ | ||
# 24. Scoping dependencies inline with lifetime scope | ||
|
||
Date: 2025-01-20 | ||
|
||
## Status | ||
|
||
Proposed | ||
|
||
## Context | ||
|
||
Adding the ability to schedule message (by providing `TimeSpan` or `DateTimeOffset`) give to user flexibility to `Send`, `Publis` and `Post`. | ||
|
||
|
||
|
||
## Decision | ||
|
||
Giving support to schedule message, it's necessary breaking on `IAmACommandProcessor` by adding these methods: | ||
|
||
```c# | ||
public interface IAmACommandProcessor | ||
{ | ||
string SchedulerSend<TRequest>(TimeSpan delay, TRequest request) where TRequest : class, IRequest; | ||
string SchedulerSend<TRequest>(DateTimeOffset delay, TRequest request) where TRequest : class, IRequest; | ||
Task<string> SchedulerSendAsync<TRequest>(TimeSpan delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
Task<string> SchedulerSendAsync<TRequest>(DateTimeOffset delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
|
||
string SchedulerPublish<TRequest>(TimeSpan delay, TRequest request) where TRequest : class, IRequest; | ||
string SchedulerPublish<TRequest>(DateTimeOffset delay, TRequest request) where TRequest : class, IRequest; | ||
Task<string> SchedulerPublishAsync<TRequest>(TimeSpan delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
Task<string> SchedulerPublishsync<TRequest>(DateTimeOffset delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
|
||
string SchedulerPost<TRequest>(TimeSpan delay, TRequest request) where TRequest : class, IRequest; | ||
string SchedulerPost<TRequest>(DateTimeOffset delay, TRequest request) where TRequest : class, IRequest; | ||
Task<string> SchedulerPostAsync<TRequest>(TimeSpan delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
Task<string> SchedulerPostAsync<TRequest>(DateTimeOffset delay, TRequest request, bool continueOnCapturedContext = true, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
} | ||
``` | ||
|
||
Scheduling can be break into 2 part (Producer & Consumer): | ||
- Producer -> Producing a message we are going to have a new interface: | ||
|
||
```c# | ||
public interface IAmAMessageScheduler | ||
{ | ||
} | ||
|
||
|
||
public interface IAmAMessageSchedulerAsync : IAmAMessageScheduler, IDisposable | ||
{ | ||
Task<string> ScheduleAsync<TRequest>(DateTimeOffset at, SchedulerFireType fireType, TRequest request, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
Task<string> ScheduleAsync<TRequest>(TimeSpan delay, SchedulerFireType fireType, TRequest request, CancellationToken cancellationToken = default) where TRequest : class, IRequest; | ||
Task CancelSchedulerAsync(string id, CancellationToken cancellationToken = default); | ||
} | ||
|
||
|
||
public interface IAmAMessageSchedulerSync : IAmAMessageScheduler, IDisposable | ||
{ | ||
string Schedule<TRequest>(DateTimeOffset at, SchedulerFireType fireType, TRequest request) where TRequest : class, IRequest; | ||
string Schedule<TRequest>(TimeSpan delay, SchedulerFireType fireType, TRequest request) where TRequest : class, IRequest; | ||
void CancelScheduler(string id); | ||
} | ||
``` | ||
|
||
- Consumer -> To avoid duplication code we are going to introduce a new message and have a handler for that: | ||
|
||
```c# | ||
public class SchedulerMessageFired : Event | ||
{ | ||
..... | ||
} | ||
|
||
|
||
public class SchedulerMessageFiredHandlerAsync(IAmACommandProcessor processor) : RequestHandlerAsync<SchedulerMessageFired> | ||
{ | ||
.... | ||
} | ||
``` | ||
|
||
So on Scheduler implementation we need to send the SchedulerMessageFired | ||
|
||
```c# | ||
public class JobExecute(IAmACommandProcessor processor) | ||
{ | ||
public async Task ExecuteAsync(Arg arg) | ||
{ | ||
await processor.SendAsync(new SchedulerMessageFired{ ... }); | ||
} | ||
} | ||
``` |
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\src\Paramore.Brighter.MessagingGateway.AWSSQS\Paramore.Brighter.MessagingGateway.AWSSQS.csproj" /> | ||
<ProjectReference Include="..\..\..\..\src\Paramore.Brighter\Paramore.Brighter.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" /> | ||
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" /> | ||
<PackageReference Include="System.Reflection.TypeExtensions" /> | ||
</ItemGroup> | ||
</Project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we would be better off overloading Send with a time, than adding a new name here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, how about SendAt, PublishAt, PostAt etc.