The second letter in the Hebrew alphabet is the ב bet/beit. Its meaning is "house". In the ancient pictographic Hebrew it was a symbol resembling a tent on a landscape.
Note: Pre-release packages are distributed via feedz.io.
The collection of the IHost related functionality used with GenericHost.
If you like or are using this project to learn or start your solution, please give it a star. Thanks!
dotnet add package Bet.Extensions.Hosting
dotnet add package Bet.Extensions.Options
To enable validation use UseOptionValidation
in Program.cs
var host = new HostBuilder()
.UseOptionValidation().Build();
Usage of ConfigureWithDataAnnotationsValidation
or ConfigureWithValidation
the same as in IWebHost
To enable registration of other services on the start up use UseStartupFilters
in Program.cs
By implementing and registering this interface with DI it is possible to trigger startup jobs for IHost
.
The simple implementation of the service that must be run at an interval specified.
- Add
MyHostedService
to the DI.
services.AddTimedHostedService(
"MachineLearningService",
options =>
{
options.Interval = TimeSpan.FromMinutes(30);
options.FailMode = FailMode.LogAndRetry;
options.RetryInterval = TimeSpan.FromSeconds(30);
options.TaskToExecuteAsync = async (sp, cancellationToken) =>
{
var job = sp.GetRequiredService<IModelCreationService>();
var logger = sp.GetRequiredService<ILogger<TimedHostedService>>();
try
{
await job.BuildModelsAsync(cancellationToken);
}
catch (Exception ex)
{
logger.LogError("{serviceName} failed with exception: {message}", nameof(TimedHostedService), ex.Message);
}
};
});