Cogito.Components
2.0.6
dotnet add package Cogito.Components --version 2.0.6
NuGet\Install-Package Cogito.Components -Version 2.0.6
<PackageReference Include="Cogito.Components" Version="2.0.6" />
<PackageVersion Include="Cogito.Components" Version="2.0.6" />
<PackageReference Include="Cogito.Components" />
paket add Cogito.Components --version 2.0.6
#r "nuget: Cogito.Components, 2.0.6"
#:package Cogito.Components@2.0.6
#addin nuget:?package=Cogito.Components&version=2.0.6
#tool nuget:?package=Cogito.Components&version=2.0.6
Cogito.Components
A small host for long-running work, built on Autofac assembly-module scanning.
Why
Most applications grow a handful of things that need to start when the process starts and keep
running until it stops — a poller, a queue consumer, a scheduler. Wiring each one by hand into the
host means every new worker touches startup. Here a worker implements IRunnable, registers itself
like any other component, and the host finds it.
Install
dotnet add package Cogito.Components
Writing a worker
[RegisterAs(typeof(IRunnable))]
public class ImportWorker : IRunnable
{
public async Task RunAsync(CancellationToken cancellationToken)
{
while (cancellationToken.IsCancellationRequested == false)
{
await ImportAsync(cancellationToken);
await Task.Delay(TimeSpan.FromMinutes(5), cancellationToken);
}
}
}
RunAsync is expected to keep running. Return when the cancellation token is signalled.
Running them
RunnableHost resolves every IRunnable into its own lifetime scope and runs them together,
surfacing failures through an UnhandledException event:
var host = new RunnableHost(container, logger);
host.UnhandledException += (s, e) => logger.Error((Exception)e.ExceptionObject, "worker failed");
await host.RunAsync(cancellationToken);
RunnableHostService wraps the same thing as an IHostedService for use with the generic host.
ISynchronizationService is the seam for coordinating workers that must not run concurrently across
instances.
License
MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Cogito.Autofac (>= 6.1.3)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.12)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Cogito.Components:
| Package | Downloads |
|---|---|
|
Cogito.Components.MassTransit
Provides automatic configuration of the MassTransit Bus. |
GitHub repositories
This package is not used by any popular GitHub repositories.