Skip to content
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

Implement asynchronous background services #61

Merged
merged 23 commits into from
Jul 7, 2023

Conversation

ric15ni
Copy link
Contributor

@ric15ni ric15ni commented Jul 7, 2023

Proposed changes

  • Add an AsyncService class to simplify the development and use of long-running background tasks.
  • Add a Louis.Hosting package with an AsyncHostedService class, derived from AsyncService, that implements IHostedService and can thus be seamlessly integrated with any IHostBuilder-based application.

Checklist of related issues / discussions

Fixes #56

Types of changes

This pull request introduces the following types of changes:

  • Bug fix
  • New feature
  • Test addition / update (no changes to non-test code)
  • Refactor (no changes in public API syntax or semantics)
  • Performance improvement (no changes in public API syntax or semantics)
  • Documentation (docs directory) update
  • Dependency addition / update
  • Changes to the build scripts
  • Changes to CI (workflows, bot / app configurations)
  • Changes to repository files (.gitattributes, .gitignore)
  • Other

Breaking changes

This pull request introduces breaking changes:

  • Yes
  • No

Checklist

  • For all types of changes:
  • For code changes only:
    • The project builds on my machine, via the provided build script, with zero warnings
    • I have added tests that prove my feature works / my fix is effective
    • I have added / modified XML documentation according to changes in code
    • I have checked that all the links I added or modified in XML documentation point to their intended destination
  • For documentation changes (docs directory) only:
    • I have built and tested documentation locally
    • I have checked that all the links I added or modified point to their intended destination

ric15ni added 21 commits July 4, 2023 13:51
…* prefix.

These methods do not handle events, they do the actual work.
- reduce the number of nested try blocks in RunAsyncCore
- add a synchronous Start method, semantically consistent with Stop
- use a private method to modify _state
@github-actions github-actions bot added area:code [issue/PR] affects project code (excluding tests). area:deps [issue/PR] adds, updates, or removes dependencies. area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code). labels Jul 7, 2023
@ric15ni ric15ni changed the title Implement async services Implement asynchronous background services Jul 7, 2023
@ric15ni
Copy link
Contributor Author

ric15ni commented Jul 7, 2023

It took me way longer than I anticipated.

A lot of time went into understanding the inner working of BackgroundService and Host and finding the simplest way to integrate AsyncService with hosting.

On a positive note, some bugs that still remained in AsyncWorker have been solved in AsyncService and the workflow of both services and users is simpler and clearer.

Copy link
Member

@rdeago rdeago left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@rdeago rdeago merged commit da82811 into Tenacom:main Jul 7, 2023
5 checks passed
@ric15ni ric15ni deleted the async-services branch July 7, 2023 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:code [issue/PR] affects project code (excluding tests). area:deps [issue/PR] adds, updates, or removes dependencies. area:docs [issue/PR] affects documentation (excluding XML documentation that is part of source code).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Asynchronous background services
2 participants