Esempio n. 1
0
        public static IHummingbirdHostBuilder AddDistributedLock(this IHummingbirdHostBuilder hostBuilder, Action <Config> action)
        {
            action = action ?? throw new ArgumentNullException(nameof(action));
            var RedisDistributedLock = DistributedLockFactory.Build(action);

            hostBuilder.Services.AddSingleton <IDistributedLock>(RedisDistributedLock);
            return(hostBuilder);
        }
        public static IWebJobsBuilder AddActorTableEntities(this IWebJobsBuilder builder, Action <ActorTableEntityOptions> optionsDelegate = null)
        {
            var options = new ActorTableEntityOptions();

            optionsDelegate?.Invoke(options);

            DistributedLockFactory.Initialise(options);

            builder.Services.AddSingleton(new TableStorageProvider(options.StorageConnectionString));
            builder.Services.AddSingleton <TableEntityProvider>();
            builder.AddExtension <ActorTableEntityBindingExtension>();

            return(builder);
        }
        public async Task <IActorTableEntityClientState <T> > GetLocked <T>(string partitionKey, string rowKey) where T : class, ITableEntity, new()
        {
            partitionKey.CheckNotNull(nameof(partitionKey));
            rowKey.CheckNotNull(nameof(rowKey));

            /* This will throw a storage exception if it fails to acquire the lock */

            Mutex = DistributedLockFactory.Get(tableStorageProvider.ToKey(partitionKey + rowKey));

            var state = new ActorTableEntityClientState <T>(Mutex, tableStorageProvider);
            await state.Hold(partitionKey, rowKey);

            return(state);
        }
        public NodeManagerComponent(IComponentSettings settings, ILogger <NodeManagerComponent> logger)
        {
            Settings             = settings;
            _masterConfiguration = new ConfigurationBuilder()
                                   .SetBasePath(Environment.CurrentDirectory)
                                   .AddJsonFile(Settings.Properties["masterConfigurationFile"], optional: false, reloadOnChange: true)
                                   .AddEnvironmentVariables()
                                   .Build();


            _logger = logger;

            _nodeSynchronizer       = new NodeSynchronizer();
            _distributedLockFactory = new DistributedLockFactory(_masterConfiguration);


            _masterWebApi = new Program(_masterConfiguration);
        }