コード例 #1
0
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            // Functions V1 has it's configuration initialized at startup time (now).
            // For Functions V2 (and for some unit tests) configuration happens earlier in the pipeline.
            if (!this.isOptionsConfigured)
            {
                this.InitializeForFunctionsV1(context);
            }

            // Throw if any of the configured options are invalid
            this.Options.Validate();

            // For 202 support
            if (this.Options.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.Options.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            this.TraceConfigurationSettings();

            var bindings = new BindingHelper(this, this.TraceHelper);

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <DurableClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs)
                       .AddConverter <IDurableClient, string>(bindings.DurableOrchestrationClientToString);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <IDurableOrchestrationClient>(this.GetClient);
            rule.BindToInput <IDurableEntityClient>(this.GetClient);
            rule.BindToInput <IDurableClient>(this.GetClient);

            string storageConnectionString = null;
            var    providerFactory         = this.durabilityProviderFactory as AzureStorageDurabilityProviderFactory;
            if (providerFactory != null)
            {
                storageConnectionString = providerFactory.GetDefaultStorageConnectionString();
            }

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            context.AddBindingRule <EntityTriggerAttribute>()
            .BindToTrigger(new EntityTriggerAttributeBindingProvider(this, context, storageConnectionString, this.TraceHelper));

            this.taskHubWorker = new TaskHubWorker(this.defaultDurabilityProvider, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.EntityMiddleware);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);
        }
コード例 #2
0
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            // Functions V1 has it's configuration initialized at startup time (now).
            // For Functions V2 (and for some unit tests) configuration happens earlier in the pipeline.
            if (!this.isOptionsConfigured)
            {
                this.InitializeForFunctionsV1(context);
            }

            if (this.nameResolver.TryResolveWholeString(this.Options.HubName, out string taskHubName))
            {
                // use the resolved task hub name
                this.Options.HubName = taskHubName;
            }

            // Throw if any of the configured options are invalid
            this.Options.Validate();

            // For 202 support
            if (this.Options.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.Options.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            this.TraceConfigurationSettings();

            var bindings = new BindingHelper(this, this.TraceHelper);

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs)
                       .AddConverter <DurableOrchestrationClient, string>(bindings.DurableOrchestrationClientToString);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(this.GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.TraceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.TraceHelper));

            this.orchestrationServiceSettings = this.GetOrchestrationServiceSettings();
            this.orchestrationService         = new AzureStorageOrchestrationService(this.orchestrationServiceSettings);
            this.taskHubWorker = new TaskHubWorker(this.orchestrationService, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);
        }
        /// <summary>
        /// Internal initialization call from the WebJobs host.
        /// </summary>
        /// <param name="context">Extension context provided by WebJobs.</param>
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            context.ApplyConfig(this, "DurableTask");

            // Register the trigger bindings
            JobHostConfiguration hostConfig = context.Config;
            ILogger logger = context.Config.LoggerFactory.CreateLogger(LoggerCategoryName);

            this.traceHelper    = new EndToEndTraceHelper(hostConfig, logger, this.LogReplayEvents);
            this.httpApiHandler = new HttpApiHandler(this, logger);

            this.lifeCycleNotificationHelper = new LifeCycleNotificationHelper(this, context);

            // Register the non-trigger bindings, which have a different model.
            var bindings = new BindingHelper(this, this.traceHelper);

            // For 202 support
            if (this.NotificationUrl == null)
            {
#pragma warning disable CS0618 // Type or member is obsolete
                this.NotificationUrl = context.GetWebhookHandler();
#pragma warning restore CS0618 // Type or member is obsolete
            }

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <string, StartOrchestrationArgs>(bindings.StringToStartOrchestrationArgs)
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(this.GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.traceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.traceHelper));

            AzureStorageOrchestrationServiceSettings settings = this.GetOrchestrationServiceSettings();
            this.orchestrationService = new AzureStorageOrchestrationService(settings);
            this.taskHubWorker        = new TaskHubWorker(this.orchestrationService, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);

            context.Config.AddService <IOrchestrationService>(this.orchestrationService);
        }
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            context.ApplyConfig(this, "DurableTask");

            // Register the trigger bindings
            JobHostConfiguration hostConfig = context.Config;

            this.traceHelper    = new EndToEndTraceHelper(hostConfig, context.Trace);
            this.httpApiHandler = new HttpApiHandler(this, context.Trace);

            // Register the non-trigger bindings, which have a different model.
            var bindings = new BindingHelper(this, this.traceHelper);

            // For 202 support
            if (this.NotificationUrl == null)
            {
                this.NotificationUrl = context.GetWebhookHandler();
            }

            // Note that the order of the rules is important
            var rule = context.AddBindingRule <OrchestrationClientAttribute>()
                       .AddConverter <JObject, StartOrchestrationArgs>(bindings.JObjectToStartOrchestrationArgs);

            rule.BindToCollector <StartOrchestrationArgs>(bindings.CreateAsyncCollector);
            rule.BindToInput <DurableOrchestrationClient>(GetClient);

            context.AddBindingRule <OrchestrationTriggerAttribute>()
            .BindToTrigger(new OrchestrationTriggerAttributeBindingProvider(this, context, this.traceHelper));

            context.AddBindingRule <ActivityTriggerAttribute>()
            .BindToTrigger(new ActivityTriggerAttributeBindingProvider(this, context, this.traceHelper));

            AzureStorageOrchestrationServiceSettings settings = this.GetOrchestrationServiceSettings();

            this.orchestrationService = new AzureStorageOrchestrationService(settings);
            this.taskHubWorker        = new TaskHubWorker(this.orchestrationService, this, this);
            this.taskHubWorker.AddOrchestrationDispatcherMiddleware(this.OrchestrationMiddleware);
        }