2020-07-14 13:24:07 +00:00
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using System.Threading.Tasks;
|
2021-05-22 11:58:21 +00:00
|
|
|
using Elsa.Extensions;
|
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
|
2021-05-22 11:58:21 +00:00
|
|
|
.AddRedis("localhost:6379,abortConnect=false")
|
|
|
|
|
.AddElsa(elsa => elsa.ConfigureDistributedLockProvider(options => options.UseRedisLockProvider())
|
2020-12-26 11:21:08 +00:00
|
|
|
.AddConsoleActivities()
|
2021-02-28 15:44:23 +00:00
|
|
|
.AddQuartzTemporalActivities()
|
2020-12-26 11:21:08 +00:00
|
|
|
.AddWorkflow<RecurringWorkflow>());
|
2020-10-18 08:40:31 +00:00
|
|
|
});
|
2020-07-14 13:24:07 +00:00
|
|
|
}
|
|
|
|
|
}
|