Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
95af9fc
WIP
alexeyshockov Feb 13, 2023
4f6eb8b
chore: let's replace Executor with multiple channel consumers, again
alexeyshockov May 14, 2023
d192f52
WORKING
alexeyshockov May 24, 2023
2491e66
WORKING again
alexeyshockov May 24, 2023
a91a0e4
WIP
alexeyshockov May 13, 2024
f49193b
WIP
alexeyshockov May 25, 2024
a5e1387
chore: BQ Options, CompletionDelay
alexeyshockov May 25, 2024
1ecb183
chore: some renaming refactoring
alexeyshockov May 25, 2024
7ec8815
chore: BackgroundQueues to BackgroundQueue
alexeyshockov May 25, 2024
f23eb81
chore: modern host builder
alexeyshockov May 27, 2024
6e0826a
WIP (Testcontainers, some fixes & refactoring)
alexeyshockov May 28, 2024
8b60571
fix: finally working tests
alexeyshockov May 30, 2024
f48be0f
chore: deps upgrade
alexeyshockov May 31, 2024
d56ffa5
SnsPublisher for later
alexeyshockov Jun 1, 2024
dafd285
WIP
alexeyshockov Jun 21, 2024
022a84c
public to internal
alexeyshockov Jun 24, 2024
06c7bd4
.NET 8 keyed services
alexeyshockov Jun 27, 2024
9fff5f8
chore: deps cleanup (after .NET 6 upgrade)
alexeyshockov Jun 28, 2024
386c64c
WIP
alexeyshockov Sep 16, 2024
a13f84d
WIP
alexeyshockov Dec 30, 2024
ad1dfbb
Rework for simplicity
alexeyshockov Jan 4, 2025
5850617
WIP
alexeyshockov Jan 7, 2025
c2e2404
WIP
alexeyshockov Jan 20, 2025
1920ba3
HandlerManager
alexeyshockov Jan 22, 2025
f9101b2
fix: tests
alexeyshockov Jan 23, 2025
0601ef8
WIP
alexeyshockov Jan 25, 2025
92b240b
WIP
alexeyshockov Jan 28, 2025
0587d0e
fix: OTEL and other refinements
alexeyshockov Feb 24, 2025
8dedbac
chore: restructuring
alexeyshockov Feb 24, 2025
0235ccd
WIP
alexeyshockov Feb 27, 2025
ed0c4f4
chore: changelog
alexeyshockov Feb 27, 2025
bd88c10
WIP
alexeyshockov Feb 28, 2025
4b97f10
chore: minor cleanup
alexeyshockov Mar 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"isRoot": true,
"tools": {
"dotnet-sonarscanner": {
"version": "5.9.2",
"version": "6.2.0",
"commands": [
"dotnet-sonarscanner"
]
},
"gitversion.tool": {
"version": "5.11.1",
"version": "5.12.0",
"commands": [
"dotnet-gitversion"
]
Expand Down
19 changes: 18 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ root = true
[*]
indent_style = space

[*.sln]
indent_style = tab

# Code files
[*.{cs,csx,vb,vbx}]
[*.{cs,csx,vb,vbx,fs,fsx,fsi}]
indent_size = 4
max_line_length = 120
insert_final_newline = true
Expand All @@ -33,3 +36,17 @@ indent_size = 4
[*.md]
trim_trailing_whitespace = true
insert_final_newline = true

# See https://github.com/dotnet/aspnetcore/blob/main/.editorconfig
[src/**/*.{cs,csx,vb,vbx,fs,fsx,fsi}]

# See https://www.jetbrains.com/help/resharper/ConfigureAwait_Analysis.html
configure_await_analysis_mode = library
# CA2007: Consider calling ConfigureAwait on the awaited task
#dotnet_diagnostic.CA2007.severity = warning

# CA2012: Use ValueTask correctly
dotnet_diagnostic.CA2012.severity = warning

# CA2013: Do not use ReferenceEquals with value types
dotnet_diagnostic.CA2013.severity = warning
7 changes: 1 addition & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
---
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
- package-ecosystem: nuget
directory: "/"
schedule:
interval: weekly
interval: monthly
17 changes: 8 additions & 9 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
---
name: Publish

on:
release:
types: [ published ]

jobs:
test:
runs-on: ubuntu-latest
env:
DOTNET_NOLOGO: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Required for GitVersion
fetch-depth: 0
- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
7.0.x
8.0.x
9.0.x
- run: dotnet restore
- run: dotnet build -c Release --no-restore
- run: dotnet test -c Release --no-build --verbosity=minimal
Expand All @@ -29,14 +28,14 @@ jobs:
env:
DOTNET_NOLOGO: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Required for GitVersion
fetch-depth: 0
- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
7.0.x
9.0.x
- run: dotnet pack -c Release
- name: Publish
run: |
Expand Down
25 changes: 12 additions & 13 deletions .github/workflows/qa.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
---
name: QA

on:
push:
branches: [ master, main ]
pull_request:
branches: [ master, main ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Full history is needed to get a proper list of changed files
fetch-depth: 0
- uses: github/super-linter@v4
- uses: github/super-linter@v7
env:
DEFAULT_BRANCH: main
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false # Only changed files
VALIDATE_ALL_CODEBASE: false # Only changed files
VALIDATE_EDITORCONFIG: true
VALIDATE_CSHARP: true
VALIDATE_CSHARP: false # Checked by SonarQube
VALIDATE_JSON: true
VALIDATE_MARKDOWN: true
VALIDATE_YAML: true
Expand All @@ -30,20 +30,19 @@ jobs:
env:
DOTNET_NOLOGO: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
# Disabling shallow clone is recommended by SonarCloud for improving relevancy of reporting
# Disabling shallow clone is recommended by SonarQube for improving relevancy of reporting
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: actions/setup-dotnet@v3
java-version: 21
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
6.0.x
7.0.x
8.0.x
9.0.x
- run: dotnet tool restore
- run: dotnet gitversion /output buildserver
- run: ./sonar-scan.sh
Expand Down
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

### Added

### Changed

### Removed

## [0.2.0] - 2025-03-12

### Changed

- Whole new design

### Removed

- LocalPost.SnsPublisher package

## [0.1.0] - 2023-01-01

### Added

- Initial release
18 changes: 0 additions & 18 deletions Directory.Build.props

This file was deleted.

45 changes: 32 additions & 13 deletions LocalPost.sln
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost", "src\LocalPost\LocalPost.csproj", "{474D2C1A-5557-4ED9-AF20-FE195D4C1AF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleWebApp", "samples\SampleWebApp\SampleWebApp.csproj", "{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.SnsPublisher", "src\LocalPost.SnsPublisher\LocalPost.SnsPublisher.csproj", "{D256C568-2B42-4DCC-AB54-15B512A99C44}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundQueueApp", "examples\BackgroundQueueApp\BackgroundQueueApp.csproj", "{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.Tests", "tests\LocalPost.Tests\LocalPost.Tests.csproj", "{0E69A423-5F70-4BA7-8015-0AB0BC4B6FD2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.SnsPublisher.Tests", "tests\LocalPost.SnsPublisher.Tests\LocalPost.SnsPublisher.Tests.csproj", "{0B8929F4-E220-45A9-A279-41F5D94A8C1B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.SqsConsumer", "src\LocalPost.SqsConsumer\LocalPost.SqsConsumer.csproj", "{30232703-C103-4F7A-9822-80F2F680A88D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.SqsConsumer.Tests", "tests\LocalPost.SqsConsumer.Tests\LocalPost.SqsConsumer.Tests.csproj", "{2F61DCD7-E4CB-4ECC-B24E-A663D12D9C03}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.KafkaConsumer", "src\LocalPost.KafkaConsumer\LocalPost.KafkaConsumer.csproj", "{D9139C53-5B9F-49E7-80DF-41C995C37E2F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Examples", "Examples", "{405721DC-F290-4191-B638-9907D5EB042B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KafkaConsumerApp", "examples\KafkaConsumerApp\KafkaConsumerApp.csproj", "{C310487A-B976-4D3E-80AF-4ADBE1C63139}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqsConsumerApp", "examples\SqsConsumerApp\SqsConsumerApp.csproj", "{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LocalPost.KafkaConsumer.Tests", "tests\LocalPost.KafkaConsumer.Tests\LocalPost.KafkaConsumer.Tests.csproj", "{734C9C76-B3D8-4AD7-8E76-B14539C3CB4D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -28,18 +34,10 @@ Global
{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E}.Release|Any CPU.Build.0 = Release|Any CPU
{D256C568-2B42-4DCC-AB54-15B512A99C44}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D256C568-2B42-4DCC-AB54-15B512A99C44}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D256C568-2B42-4DCC-AB54-15B512A99C44}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D256C568-2B42-4DCC-AB54-15B512A99C44}.Release|Any CPU.Build.0 = Release|Any CPU
{0E69A423-5F70-4BA7-8015-0AB0BC4B6FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E69A423-5F70-4BA7-8015-0AB0BC4B6FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E69A423-5F70-4BA7-8015-0AB0BC4B6FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0E69A423-5F70-4BA7-8015-0AB0BC4B6FD2}.Release|Any CPU.Build.0 = Release|Any CPU
{0B8929F4-E220-45A9-A279-41F5D94A8C1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B8929F4-E220-45A9-A279-41F5D94A8C1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B8929F4-E220-45A9-A279-41F5D94A8C1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B8929F4-E220-45A9-A279-41F5D94A8C1B}.Release|Any CPU.Build.0 = Release|Any CPU
{30232703-C103-4F7A-9822-80F2F680A88D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30232703-C103-4F7A-9822-80F2F680A88D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30232703-C103-4F7A-9822-80F2F680A88D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -48,5 +46,26 @@ Global
{2F61DCD7-E4CB-4ECC-B24E-A663D12D9C03}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F61DCD7-E4CB-4ECC-B24E-A663D12D9C03}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2F61DCD7-E4CB-4ECC-B24E-A663D12D9C03}.Release|Any CPU.Build.0 = Release|Any CPU
{D9139C53-5B9F-49E7-80DF-41C995C37E2F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D9139C53-5B9F-49E7-80DF-41C995C37E2F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D9139C53-5B9F-49E7-80DF-41C995C37E2F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9139C53-5B9F-49E7-80DF-41C995C37E2F}.Release|Any CPU.Build.0 = Release|Any CPU
{C310487A-B976-4D3E-80AF-4ADBE1C63139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C310487A-B976-4D3E-80AF-4ADBE1C63139}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C310487A-B976-4D3E-80AF-4ADBE1C63139}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C310487A-B976-4D3E-80AF-4ADBE1C63139}.Release|Any CPU.Build.0 = Release|Any CPU
{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD}.Release|Any CPU.Build.0 = Release|Any CPU
{734C9C76-B3D8-4AD7-8E76-B14539C3CB4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{734C9C76-B3D8-4AD7-8E76-B14539C3CB4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{734C9C76-B3D8-4AD7-8E76-B14539C3CB4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{734C9C76-B3D8-4AD7-8E76-B14539C3CB4D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{46FC61E6-D0FB-4D7D-A81B-20EF8D8D1F4E} = {405721DC-F290-4191-B638-9907D5EB042B}
{C310487A-B976-4D3E-80AF-4ADBE1C63139} = {405721DC-F290-4191-B638-9907D5EB042B}
{2778AEBD-0345-4F79-9E93-73AFAB6C7BCD} = {405721DC-F290-4191-B638-9907D5EB042B}
EndGlobalSection
EndGlobal
51 changes: 48 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,53 @@
# LocalPost

[![NuGet package](https://img.shields.io/nuget/dt/LocalPost)](https://www.nuget.org/packages/LocalPost/)
[![Code coverage](https://img.shields.io/sonar/coverage/alexeyshockov_LocalPost.NET?server=https%3A%2F%2Fsonarcloud.io)](https://sonarcloud.io/project/overview?id=alexeyshockov_LocalPost.NET)

Simple .NET in-memory background queue ([System.Threading.Channels](https://learn.microsoft.com/de-de/dotnet/api/system.threading.channels?view=net-6.0) based).

## Alternatives
## Background tasks

There are multiple ways to run background tasks in .NET. The most common are:

## Usage

### Installation

For the core library:

```shell
dotnet add package LocalPost
```

AWS SQS, Kafka and other integrations are provided as separate packages, like:

```shell
dotnet add package LocalPost.SqsConsumer
dotnet add package LocalPost.KafkaConsumer
```

### .NET 8 asynchronous background services handling

Before version 8 .NET runtime handled start/stop of the services only synchronously, but now it is possible to enable
concurrent handling of the services. This is done by setting `HostOptions` property `ConcurrentServiceExecution`
to `true`:

See for details:
- https://github.com/dotnet/runtime/blob/v8.0.0/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs
- https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.Extensions.Hosting/src/HostOptions.cs

## Similar projects

- [Coravel queue](https://docs.coravel.net/Queuing/) — a simple job queue

More complex jobs management / scheduling:
- [Hangfire](https://www.hangfire.io/) — background job scheduler. Supports advanced scheduling, persistence and jobs distribution across multiple workers.

Service bus (for bigger solutions):
- [JustSaying](https://github.com/justeattakeaway/JustSaying)
- [NServiceBus](https://docs.particular.net/nservicebus/)
- [MassTransit](https://masstransit.io/)

## Inspiration

- [Coravel queue](https://docs.coravel.net/Queuing/)/event broadcasting — only invocable queueing, event broadcasting is different from consuming a queue
- [Hangfire](https://www.hangfire.io/) — for persistent queues (means payload serialisation), LocalPost is completely about in-memory ones
- [FastStream](https://github.com/airtai/faststream)
Loading