Beispiel #1
0
        public async Task StopAsync_IsIdempotent()
        {
            int numStops = 3;
            RedisOrchestrationService service = TestHelpers.GetTestOrchestrationService();

            for (int i = 0; i < numStops; i++)
            {
                await service.StopAsync();
            }
        }
Beispiel #2
0
        public RedisDurabilityProviderFactory(IOptions <DurableTaskOptions> options, IConnectionStringResolver connectionStringResolver)
        {
            this.defaultConnectionName = options.Value.StorageProvider["connectionName"] as string;
            string redisConnectionString = connectionStringResolver.Resolve(this.defaultConnectionName);

            this.defaultHubName     = options.Value.HubName;
            this.connectionResolver = connectionStringResolver;
            var defaultTaskHubService = new RedisOrchestrationService(new RedisOrchestrationServiceSettings()
            {
                TaskHubName           = this.defaultHubName,
                RedisConnectionString = redisConnectionString,
            });

            this.defaultProvider = new DurabilityProvider("Redis", defaultTaskHubService, defaultTaskHubService, this.defaultConnectionName);
        }
Beispiel #3
0
        public async Task DeleteTaskHub_DeletesAllKeysInRelevantNamespace()
        {
            string otherTaskHub = "othertaskhub";
            ConnectionMultiplexer redisConnection = await TestHelpers.GetRedisConnection();

            string    taskHub  = nameof(DeleteTaskHub_DeletesAllKeysInRelevantNamespace);
            IDatabase database = redisConnection.GetDatabase();

            try
            {
                await Task.WhenAll(
                    database.StringSetAsync($"{taskHub}.string", "string"),
                    database.ListLeftPushAsync($"{taskHub}.list", "value1"),
                    database.HashSetAsync($"{taskHub}.hash", "key", "value"),
                    database.StringSetAsync($"{otherTaskHub}.string", "string")
                    );

                RedisOrchestrationService service = TestHelpers.GetTestOrchestrationService(taskHub);
                await service.DeleteAsync();

                // Assert all task hub values were deleted
                string taskHubStringValue = await database.StringGetAsync($"{taskHub}.string");

                Assert.Null(taskHubStringValue);
                string taskHubHashValue = await database.HashGetAsync($"{taskHub}.hash", "key");

                Assert.Null(taskHubHashValue);
                RedisValue[] taskHubListValue = await database.ListRangeAsync($"{taskHub}.list", 0);

                Assert.Empty(taskHubListValue);

                // Assert non-task hub values were not deleted
                string otherTaskHubStringValue = await database.StringGetAsync($"{otherTaskHub}.string");

                Assert.Equal("string", otherTaskHubStringValue);
            }
            finally
            {
                database.KeyDelete($"{taskHub}.string");
                database.KeyDelete($"{taskHub}.list");
                database.KeyDelete($"{taskHub}.hash");
                database.KeyDelete($"{otherTaskHub}.string");
            }
        }
Beispiel #4
0
        public DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute)
        {
            if (string.IsNullOrEmpty(attribute.TaskHub) && string.IsNullOrEmpty(attribute.ConnectionName))
            {
                return(this.defaultProvider);
            }

            if (string.Equals(attribute.TaskHub, this.defaultHubName) && string.Equals(attribute.ConnectionName, this.defaultConnectionName))
            {
                return(this.defaultProvider);
            }

            string redisConnectionString     = this.connectionResolver.Resolve(attribute.ConnectionName);
            var    redisOrchestartionService = new RedisOrchestrationService(new RedisOrchestrationServiceSettings()
            {
                TaskHubName           = attribute.TaskHub,
                RedisConnectionString = redisConnectionString,
            });

            return(new DurabilityProvider("Redis", redisOrchestartionService, redisOrchestartionService, attribute.ConnectionName));
        }
Beispiel #5
0
 public async Task UnstartedService_CanBeSafelyStopped()
 {
     RedisOrchestrationService service = TestHelpers.GetTestOrchestrationService();
     await service.StopAsync();
 }