Change async event delivery to single goroutine with events channel queue #231
+169
−36
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.
Goal
In case of heavy load notifier created too many goroutines for sending events thus consuming a lot of resources.
Adding a single goroutine with a channel will limit usage of resources and allow events to get queued to be sent instead of trying to send everything at once.
Changeset
Added a single goroutine as a default strategy for the async delivery. On failure events are dropped.
Goroutine has two ways of handling graceful shutdown. Either react to a signal which it's registered to or react to main program context sending
Done()
.Added configuration option for passing MainProgramContext.
Testing
Existing maze-runner tests can be used