2020-07-14 13:24:07 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-12-23 11:38:09 +00:00
|
|
|
using Elsa.Activities.Timers;
|
2020-07-14 13:24:07 +00:00
|
|
|
|
|
|
|
|
namespace Elsa.Samples.DistributedLock
|
|
|
|
|
{
|
2020-10-18 08:40:31 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// Demonstrates the use of a distributed locking provider.
|
|
|
|
|
/// Make sure that you have a Redis host installed or use the docker-compose.yaml file to run it on Docker.
|
|
|
|
|
/// </summary>
|
2020-07-14 13:24:07 +00:00
|
|
|
internal static class Program
|
|
|
|
|
{
|
2020-10-18 08:40:31 +00:00
|
|
|
private static async Task Main() => await CreateHostBuilder().UseConsoleLifetime().Build().RunAsync();
|
2020-07-14 13:24:07 +00:00
|
|
|
|
2020-12-12 13:07:17 +00:00
|
|
|
private static IHostBuilder CreateHostBuilder() =>
|
2020-07-14 13:24:07 +00:00
|
|
|
Host.CreateDefaultBuilder()
|
2020-10-18 08:40:31 +00:00
|
|
|
.ConfigureServices(
|
2020-12-12 13:07:17 +00:00
|
|
|
(_, services) =>
|
2020-10-18 08:40:31 +00:00
|
|
|
{
|
|
|
|
|
services
|
2020-12-11 20:03:49 +00:00
|
|
|
.AddElsa(options => options.UseRedisLockProvider("localhost:6379,abortConnect=false"))
|
2020-10-18 08:40:31 +00:00
|
|
|
.AddConsoleActivities()
|
2020-12-23 11:38:09 +00:00
|
|
|
.AddTimerActivities(options => options.UseQuartzProvider())
|
2020-10-18 08:40:31 +00:00
|
|
|
.AddWorkflow<RecurringWorkflow>();
|
|
|
|
|
});
|
2020-07-14 13:24:07 +00:00
|
|
|
}
|
|
|
|
|
}
|