/// <summary> /// Initializes a new instance of the <see cref="DurableTaskExtension"/>. /// </summary> /// <param name="options">The configuration options for this extension.</param> /// <param name="loggerFactory">The logger factory used for extension-specific logging and orchestration tracking.</param> /// <param name="nameResolver">The name resolver to use for looking up application settings.</param> /// <param name="orchestrationServiceFactory">The factory used to create orchestration service based on the configured storage provider.</param> /// <param name="durableHttpMessageHandlerFactory">The HTTP message handler that handles HTTP requests and HTTP responses.</param> /// <param name="lifeCycleNotificationHelper">The lifecycle notification helper used for custom orchestration tracking.</param> public DurableTaskExtension( IOptions <DurableTaskOptions> options, ILoggerFactory loggerFactory, INameResolver nameResolver, IDurabilityProviderFactory orchestrationServiceFactory, IDurableHttpMessageHandlerFactory durableHttpMessageHandlerFactory = null, ILifeCycleNotificationHelper lifeCycleNotificationHelper = null) { // Options will be null in Functions v1 runtime - populated later. this.Options = options?.Value ?? new DurableTaskOptions(); this.nameResolver = nameResolver ?? throw new ArgumentNullException(nameof(nameResolver)); if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } ILogger logger = loggerFactory.CreateLogger(LoggerCategoryName); this.TraceHelper = new EndToEndTraceHelper(logger, this.Options.Tracing.TraceReplayEvents); this.LifeCycleNotificationHelper = lifeCycleNotificationHelper ?? this.CreateLifeCycleNotificationHelper(); this.durabilityProviderFactory = orchestrationServiceFactory; this.defaultDurabilityProvider = this.durabilityProviderFactory.GetDurabilityProvider(); this.HttpApiHandler = new HttpApiHandler(this, logger); this.isOptionsConfigured = true; if (durableHttpMessageHandlerFactory == null) { durableHttpMessageHandlerFactory = new DurableHttpMessageHandlerFactory(); } DurableHttpClientFactory durableHttpClientFactory = new DurableHttpClientFactory(); this.durableHttpClient = durableHttpClientFactory.GetClient(durableHttpMessageHandlerFactory); }
internal DurableTaskExtension( IOptions <DurableTaskOptions> options, ILoggerFactory loggerFactory, INameResolver nameResolver, IDurabilityProviderFactory orchestrationServiceFactory, IConnectionStringResolver connectionStringResolver, IDurableHttpMessageHandlerFactory durableHttpMessageHandlerFactory) : this(options, loggerFactory, nameResolver, orchestrationServiceFactory, durableHttpMessageHandlerFactory) { this.connectionStringResolver = connectionStringResolver; }
private void InitializeForFunctionsV1(ExtensionConfigContext context) { #if FUNCTIONS_V1 context.ApplyConfig(this.Options, "DurableTask"); ILogger logger = context.Config.LoggerFactory.CreateLogger(LoggerCategoryName); this.TraceHelper = new EndToEndTraceHelper(logger, this.Options.Tracing.TraceReplayEvents); this.connectionStringResolver = new WebJobsConnectionStringProvider(); this.durabilityProviderFactory = new AzureStorageDurabilityProviderFactory(new OptionsWrapper <DurableTaskOptions>(this.Options), this.connectionStringResolver); this.defaultDurabilityProvider = this.durabilityProviderFactory.GetDurabilityProvider(); this.nameResolver = context.Config.NameResolver; this.LifeCycleNotificationHelper = this.CreateLifeCycleNotificationHelper(); this.HttpApiHandler = new HttpApiHandler(this, logger); #endif }
/// <summary> /// Initializes a new instance of the <see cref="DurableTaskExtension"/>. /// </summary> /// <param name="options">The configuration options for this extension.</param> /// <param name="loggerFactory">The logger factory used for extension-specific logging and orchestration tracking.</param> /// <param name="nameResolver">The name resolver to use for looking up application settings.</param> /// <param name="orchestrationServiceFactory">The factory used to create orchestration service based on the configured storage provider.</param> /// <param name="durableHttpMessageHandlerFactory">The HTTP message handler that handles HTTP requests and HTTP responses.</param> /// <param name="hostLifetimeService">The host shutdown notification service for detecting and reacting to host shutdowns.</param> /// <param name="lifeCycleNotificationHelper">The lifecycle notification helper used for custom orchestration tracking.</param> /// <param name="messageSerializerSettingsFactory">The factory used to create <see cref="JsonSerializerSettings"/> for message settings.</param> /// <param name="errorSerializerSettingsFactory">The factory used to create <see cref="JsonSerializerSettings"/> for error settings.</param> public DurableTaskExtension( IOptions <DurableTaskOptions> options, ILoggerFactory loggerFactory, INameResolver nameResolver, IDurabilityProviderFactory orchestrationServiceFactory, IApplicationLifetimeWrapper hostLifetimeService, IDurableHttpMessageHandlerFactory durableHttpMessageHandlerFactory = null, ILifeCycleNotificationHelper lifeCycleNotificationHelper = null, IMessageSerializerSettingsFactory messageSerializerSettingsFactory = null, IErrorSerializerSettingsFactory errorSerializerSettingsFactory = null) { // Options will be null in Functions v1 runtime - populated later. this.Options = options?.Value ?? new DurableTaskOptions(); this.nameResolver = nameResolver ?? throw new ArgumentNullException(nameof(nameResolver)); this.ResolveAppSettingOptions(); if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } ILogger logger = loggerFactory.CreateLogger(LoggerCategoryName); this.TraceHelper = new EndToEndTraceHelper(logger, this.Options.Tracing.TraceReplayEvents); this.LifeCycleNotificationHelper = lifeCycleNotificationHelper ?? this.CreateLifeCycleNotificationHelper(); this.durabilityProviderFactory = orchestrationServiceFactory; this.defaultDurabilityProvider = this.durabilityProviderFactory.GetDurabilityProvider(); this.isOptionsConfigured = true; if (durableHttpMessageHandlerFactory == null) { durableHttpMessageHandlerFactory = new DurableHttpMessageHandlerFactory(); } DurableHttpClientFactory durableHttpClientFactory = new DurableHttpClientFactory(); this.durableHttpClient = durableHttpClientFactory.GetClient(durableHttpMessageHandlerFactory); this.MessageDataConverter = this.CreateMessageDataConverter(messageSerializerSettingsFactory); this.ErrorDataConverter = this.CreateErrorDataConverter(errorSerializerSettingsFactory); this.HttpApiHandler = new HttpApiHandler(this, logger); #if !FUNCTIONS_V1 // The RPC server is started when the extension is initialized. // The RPC server is stopped when the host has finished shutting down. hostLifetimeService.OnStopped.Register(this.StopLocalRcpServer); #endif }
/// <summary> /// Initializes a new instance of the <see cref="DurableClientFactory"/> class. /// </summary> /// <param name="defaultDurableClientOptions">Default Options to Build Durable Clients.</param> /// <param name="orchestrationServiceFactory">The factory used to create orchestration service based on the configured storage provider.</param> /// <param name="loggerFactory">The logger factory used for extension-specific logging and orchestration tracking.</param> /// <param name="durableTaskOptions">The configuration options for this extension.</param> /// <param name="messageSerializerSettingsFactory">The factory used to create <see cref="JsonSerializerSettings"/> for message settings.</param> public DurableClientFactory( IOptions <DurableClientOptions> defaultDurableClientOptions, IOptions <DurableTaskOptions> durableTaskOptions, IDurabilityProviderFactory orchestrationServiceFactory, ILoggerFactory loggerFactory, IMessageSerializerSettingsFactory messageSerializerSettingsFactory = null) { this.logger = loggerFactory.CreateLogger(DurableTaskExtension.LoggerCategoryName); this.durabilityProviderFactory = orchestrationServiceFactory; this.defaultDurableClientOptions = defaultDurableClientOptions.Value; this.durableTaskOptions = durableTaskOptions?.Value ?? new DurableTaskOptions(); this.MessageDataConverter = DurableTaskExtension.CreateMessageDataConverter(messageSerializerSettingsFactory); this.TraceHelper = new EndToEndTraceHelper(this.logger, this.durableTaskOptions.Tracing.TraceReplayEvents); }
private static IWebJobsBuilder AddMultipleDurabilityProvidersDurableTask(this IWebJobsBuilder builder, IOptions <DurableTaskOptions> options, IEnumerable <IDurabilityProviderFactory> durabilityProviderFactories = null) { for (int i = 0; i < durabilityProviderFactories?.Count(); i++) { IDurabilityProviderFactory factory = durabilityProviderFactories.ElementAt(i); builder.Services.AddSingleton(typeof(IDurabilityProviderFactory), factory); } builder.Services.AddSingleton(options); var serviceCollection = builder.AddExtension <DurableTaskExtension>() .BindOptions <DurableTaskOptions>() .Services.AddSingleton <IConnectionStringResolver, WebJobsConnectionStringProvider>(); serviceCollection.TryAddSingleton <IApplicationLifetimeWrapper, HostLifecycleService>(); #pragma warning disable CS0612 // Type or member is obsolete serviceCollection.TryAddSingleton <IPlatformInformationService, DefaultPlatformInformationProvider>(); #pragma warning restore CS0612 // Type or member is obsolete return(builder); }