/// <inheritdoc/> public DurabilityProvider GetDurabilityProvider() { if (this.defaultProvider == null) { var settings = this.GetNetheriteOrchestrationServiceSettings(); if (this.TraceToBlob && BlobLogger == null) { BlobLogger = new BlobLogger(settings.ResolvedStorageConnectionString, settings.WorkerId); } var key = new DurableClientAttribute() { TaskHub = settings.HubName, ConnectionName = settings.ResolvedStorageConnectionString, }; this.defaultProvider = this.cachedProviders.GetOrAdd(key, _ => { var service = new NetheriteOrchestrationService(settings, this.loggerFactory); return(new NetheriteProvider(service, settings)); }); } return(this.defaultProvider); }
// 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); }
public override DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute) { AzureStorageDurabilityProvider provider = base.GetDurabilityProvider(attribute) as AzureStorageDurabilityProvider; provider.MaximumDelayTime = TimeSpan.FromSeconds(10); provider.LongRunningTimerIntervalLength = TimeSpan.FromSeconds(3); return(provider); }
private IDurableOrchestrationClient GetDurableClient(IOrchestrationServiceClient orchestrationServiceClientMockObject) { var storageProvider = new DurabilityProvider("test", new Mock <IOrchestrationService>().Object, orchestrationServiceClientMockObject, "test"); DurableClientOptions durableClientOptions = new DurableClientOptions { ConnectionName = "Storage", TaskHub = "TestTaskHub", }; DurableTaskOptions durableTaskOptions = new DurableTaskOptions(); DurableClientAttribute attribute = new DurableClientAttribute(durableClientOptions); MessagePayloadDataConverter messagePayloadDataConverter = new MessagePayloadDataConverter(new JsonSerializerSettings(), true); var traceHelper = new EndToEndTraceHelper(new NullLogger <EndToEndTraceHelper>(), durableTaskOptions.Tracing.TraceReplayEvents); var durableOrchestrationClient = (IDurableOrchestrationClient) new DurableClient(storageProvider, null, attribute, messagePayloadDataConverter, traceHelper, durableTaskOptions); return(durableOrchestrationClient); }
// Called by the Durable client binding infrastructure public DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute) { var settings = this.GetNetheriteOrchestrationServiceSettings(attribute.TaskHub); if (string.Equals(this.defaultProvider.Settings.HubName, settings.HubName, StringComparison.OrdinalIgnoreCase) && string.Equals(this.defaultProvider.Settings.ResolvedStorageConnectionString, settings.ResolvedStorageConnectionString, StringComparison.OrdinalIgnoreCase)) { return(this.defaultProvider); } DurableClientAttribute key = new DurableClientAttribute() { TaskHub = settings.HubName, ConnectionName = settings.ResolvedStorageConnectionString, }; return(this.cachedProviders.GetOrAdd(key, _ => { //TODO support client-only version var service = new NetheriteOrchestrationService(settings, this.loggerFactory); return new NetheriteProvider(service, settings); })); }
/// <summary> /// Gets a <see cref="IDurableClient"/> using configuration from a <see cref="DurableClientOptions"/> instance. /// </summary> /// <param name="durableClientOptions">options containing the client configuration parameters.</param> /// <returns>Returns a <see cref="IDurableClient"/> instance. The returned instance may be a cached instance.</returns> public IDurableClient CreateClient(DurableClientOptions durableClientOptions) { if (durableClientOptions == null) { throw new ArgumentException("Please configure 'DurableClientOptions'"); } if (string.IsNullOrWhiteSpace(durableClientOptions.TaskHub)) { throw new ArgumentException("Please provide value for 'TaskHub'"); } DurableClientAttribute attribute = new DurableClientAttribute(durableClientOptions); DurableClient client = this.cachedClients.GetOrAdd( attribute, attr => { DurabilityProvider innerClient = this.durabilityProviderFactory.GetDurabilityProvider(attribute); return(new DurableClient(innerClient, null, attribute, this.MessageDataConverter, this.TraceHelper, this.durableTaskOptions)); }); return(client); }
public override DurabilityProvider GetDurabilityProvider(DurableClientAttribute attribute) { return(this.GetDurabilityProvider()); }
internal DurableClientMock(DurabilityProvider serviceClient, DurableTaskExtension config, DurableClientAttribute attribute) : base(serviceClient, config, config.HttpApiHandler, attribute) { }
static string GetDurabilityProviderKey(DurableClientAttribute attribute) { return(attribute.ConnectionName + "|" + attribute.TaskHub); }