// Called by the Durable client binding infrastructure
        public DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute)
        {
            // TODO: Much of this logic should go into the base class
            if (string.IsNullOrEmpty(attribute.ConnectionName) &&
                string.IsNullOrEmpty(attribute.TaskHub))
            {
                return(this.GetDurabilityProvider());
            }

            lock (this.clientProviders)
            {
                string key = GetDurabilityProviderKey(attribute);
                if (this.clientProviders.TryGetValue(key, out DurabilityProvider clientProvider))
                {
                    return(clientProvider);
                }

                SqlDurabilityOptions        clientOptions = this.GetSqlOptions(attribute);
                IOrchestrationServiceClient serviceClient =
                    new SqlOrchestrationService(clientOptions.GetOrchestrationServiceSettings(
                                                    this.extensionOptions,
                                                    this.connectionStringResolver));
                clientProvider = new SqlDurabilityProvider(
                    this.GetOrchestrationService(),
                    clientOptions,
                    serviceClient);

                this.clientProviders.Add(key, clientProvider);
                return(clientProvider);
            }
        }
        SqlDurabilityOptions GetSqlOptions(DurableClientAttribute attribute)
        {
            var options = new SqlDurabilityOptions
            {
                TaskHubName   = this.extensionOptions.HubName,
                LoggerFactory = this.loggerFactory,
            };

            // Deserialize the configuration directly from the host.json settings.
            // Note that not all settings can be applied from JSON.
            string configJson = JsonConvert.SerializeObject(this.extensionOptions.StorageProvider);

            JsonConvert.PopulateObject(configJson, options);

            // Attribute properties can override host.json settings.
            if (!string.IsNullOrEmpty(attribute.ConnectionName))
            {
                options.ConnectionStringName = attribute.ConnectionName;
            }

            if (!string.IsNullOrEmpty(attribute.TaskHub))
            {
                options.TaskHubName = attribute.TaskHub;
            }

            return(options);
        }
예제 #3
0
 public SqlDurabilityProvider(
     SqlOrchestrationService service,
     SqlDurabilityOptions durabilityOptions)
     : base(Name, service, service, durabilityOptions.ConnectionStringName)
 {
     this.service           = service ?? throw new ArgumentNullException(nameof(service));
     this.durabilityOptions = durabilityOptions;
 }
        // Called by the Durable trigger binding infrastructure
        public DurabilityProvider GetDurabilityProvider()
        {
            if (this.defaultProvider == null)
            {
                SqlDurabilityOptions    sqlProviderOptions = this.GetDefaultSqlOptions();
                SqlOrchestrationService service            = this.GetOrchestrationService();
                this.defaultProvider = new SqlDurabilityProvider(service, sqlProviderOptions);
            }

            return(this.defaultProvider);
        }
        SqlOrchestrationServiceSettings GetOrchestrationServiceSettings()
        {
            if (this.orchestrationServiceSettings == null)
            {
                SqlDurabilityOptions options = this.GetDefaultSqlOptions();
                this.orchestrationServiceSettings = options.GetOrchestrationServiceSettings(
                    this.extensionOptions,
                    this.connectionStringResolver);
            }

            return(this.orchestrationServiceSettings);
        }