Example #1
0
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            // apply at eventProcessorOptions level (maxBatchSize, prefetchCount)
            context.ApplyConfig(_options, "eventHub");

            // apply at config level (batchCheckpointFrequency)
            context.ApplyConfig(this, "eventHub");

            _defaultStorageString = context.Config.StorageConnectionString;

            context
            .AddConverter <string, EventData>(ConvertString2EventData)
            .AddConverter <EventData, string>(ConvertEventData2String)
            .AddConverter <byte[], EventData>(ConvertBytes2EventData)
            .AddConverter <EventData, byte[]>(ConvertEventData2Bytes)
            .AddOpenConverter <OpenType.Poco, EventData>(ConvertPocoToEventData);

            // register our trigger binding provider
            INameResolver     nameResolver = context.Config.NameResolver;
            IConverterManager cm           = context.Config.GetService <IConverterManager>();
            var triggerBindingProvider     = new EventHubTriggerAttributeBindingProvider(nameResolver, cm, this, context.Config.LoggerFactory);

            context.AddBindingRule <EventHubTriggerAttribute>()
            .BindToTrigger(triggerBindingProvider);

            // register our binding provider
            context.AddBindingRule <EventHubAttribute>()
            .BindToCollector(BuildFromAttribute);
        }
Example #2
0
            public void Initialize(ExtensionConfigContext context)
            {
                _messageEnqueuedWatcherGetter = context.PerHostServices.GetService <ContextAccessor <IMessageEnqueuedWatcher> >();
                _accountProvider = context.Config.GetService <IStorageAccountProvider>();

                context.ApplyConfig(context.Config.Queues, "queues");

                // IStorageQueueMessage is the core testing interface
                var binding = context.AddBindingRule <QueueAttribute>();

                binding
                .AddConverter <byte[], IStorageQueueMessage>(ConvertByteArrayToCloudQueueMessage)
                .AddConverter <string, IStorageQueueMessage>(ConvertStringToCloudQueueMessage)
                .AddOpenConverter <OpenType.Poco, IStorageQueueMessage>(ConvertPocoToCloudQueueMessage);

                context // global converters, apply to multiple attributes.
                .AddConverter <IStorageQueueMessage, byte[]>(ConvertCloudQueueMessageToByteArray)
                .AddConverter <IStorageQueueMessage, string>(ConvertCloudQueueMessageToString)
                .AddConverter <CloudQueueMessage, IStorageQueueMessage>(ConvertToStorageQueueMessage);

                var builder = new QueueBuilder(this);

                binding.AddValidator(ValidateQueueAttribute);

                binding.SetPostResolveHook(ToWriteParameterDescriptorForCollector)
                .BindToCollector <IStorageQueueMessage>(this);

                binding.SetPostResolveHook(ToReadWriteParameterDescriptorForCollector)
                .BindToInput <IStorageQueue>(builder);

                binding.SetPostResolveHook(ToReadWriteParameterDescriptorForCollector)
                .BindToInput <CloudQueue>(builder);
            }
        void IExtensionConfigProvider.Initialize(ExtensionConfigContext context)
        {
            ConfigureLoaderHooks();

            context.ApplyConfig(this, "DurableTask");

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

            this.traceHelper    = new EndToEndTraceHelper(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));
        }
        /// <inheritdoc />
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }

            var metadata = new ConfigMetadata();

            context.ApplyConfig(metadata, "sendgrid");
            this.ToAddress   = SendGridHelpers.Apply(this.ToAddress, metadata.To);
            this.FromAddress = SendGridHelpers.Apply(this.FromAddress, metadata.From);

            if (string.IsNullOrEmpty(this.ApiKey))
            {
                INameResolver nameResolver = context.Config.NameResolver;
                this.ApiKey = nameResolver.Resolve(AzureWebJobsSendGridApiKeyName);
            }

            context
            .AddConverter <string, SendGridMessage>(SendGridHelpers.CreateMessage)
            .AddConverter <JObject, SendGridMessage>(SendGridHelpers.CreateMessage)
            .AddBindingRule <SendGridAttribute>()
            .AddValidator(ValidateBinding)
            .BindToCollector <SendGridMessage>(CreateCollector);
        }
Example #5
0
        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
        }
Example #6
0
        private void InitializeForFunctionsV1(ExtensionConfigContext context)
        {
#if !NETSTANDARD2_0
            context.ApplyConfig(this.Options, "DurableTask");

            ILogger logger = context.Config.LoggerFactory.CreateLogger(LoggerCategoryName);

            this.TraceHelper                 = new EndToEndTraceHelper(logger, this.Options.LogReplayEvents);
            this.HttpApiHandler              = new HttpApiHandler(this, logger);
            this.connectionStringResolver    = new WebJobsConnectionStringProvider();
            this.LifeCycleNotificationHelper = this.CreateLifeCycleNotificationHelper();
            this.nameResolver                = context.Config.NameResolver;
#endif
        }
        /// <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);
        }
        public void Initialize(ExtensionConfigContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            context.ApplyConfig(this, "firebaseCloudMessaging");

            var nameResolver     = context.Config.GetService <INameResolver>();
            var extensions       = context.Config.GetService <IExtensionRegistry>();
            var converterManager = context.Config.GetService <IConverterManager>();

            var triggerBindingProvider = new FirebaseCloudMessageTriggerAttributeBindingProvider(
                nameResolver,
                converterManager,
                this,
                context.Config.LoggerFactory
                );

            extensions.RegisterExtension <ITriggerBindingProvider>(triggerBindingProvider);

            context.AddBindingRule <FirebaseCloudMessagingTriggerAttribute>()
            .BindToTrigger(triggerBindingProvider);
        }