コード例 #1
0
        Task IFeature.Activate(JasperRuntime runtime, IGenerationConfig generation)
        {
            return(Task.Factory.StartNew(() =>
            {
                // TODO -- will need to be smart enough to do the conglomerate
                // generation config of the base, with service bus specific stuff
                _graph.Compile(generation, runtime.Container);

                var transports = runtime.Container.GetAllInstances <ITransport>().ToArray();

                Channels.UseTransports(transports);

                configureSerializationOrder(runtime);

                // TODO
                // Done -- 1. Start up transports
                // 2. Start up subscriptions when ready

                var pipeline = runtime.Container.GetInstance <IHandlerPipeline>();

                // TODO -- might parallelize this later
                foreach (var transport in transports)
                {
                    transport.Start(pipeline, Channels);

                    Channels
                    .Where(x => x.Uri.Scheme == transport.Protocol && x.Sender == null)
                    .Each(x =>
                    {
                        x.Sender = new NulloSender(transport, x.Uri);
                    });
                }
            }));
        }
コード例 #2
0
        public void interfaces_are_applied_correctly()
        {
            var general   = HandlerCall.For <ConcreteHandler>(x => x.General(null));
            var specific1 = HandlerCall.For <ConcreteHandler>(x => x.Specific1(null));
            var specific2 = HandlerCall.For <ConcreteHandler>(x => x.Specific2(null));

            theGraph.Add(general);
            theGraph.Add(specific1);
            theGraph.Add(specific2);

            theGraph.ShouldHaveCount(2);
            theGraph.Compile();

            theGraph.ShouldHaveCount(2);

            theGraph.ChainFor(typeof(Concrete1)).Last().ShouldBeOfType <HandlerCall>()
            .InputType().ShouldBe(typeof(IMessage));

            theGraph.ChainFor(typeof(Concrete2)).Last().ShouldBeOfType <HandlerCall>()
            .InputType().ShouldBe(typeof(IMessage));
        }
コード例 #3
0
        public Task<BehaviorChain[]> BuildChains(BehaviorGraph graph, IPerfTimer timer)
        {
            var finders = HandlerSources.Select(x => x.FindCalls(graph.ApplicationAssembly)).ToArray();
            return Task.WhenAll(finders).ContinueWith(all =>
            {
                var handlers = new HandlerGraph();

                var allCalls = all.Result.SelectMany(x => x).Distinct();

                handlers.Add(allCalls);

                handlers.Compile();

                return handlers.OfType<BehaviorChain>().ToArray();
            });
        }
コード例 #4
0
ファイル: MessagingRoot.cs プロジェクト: brokenbot/jasper
        public async Task Activate(LocalWorkerSender localWorker, CapabilityGraph capabilities, JasperRuntime runtime,
                                   GenerationRules generation, PerfTimer timer)
        {
            timer.MarkStart("ServiceBusActivator");

            _handlers.Compile(generation, runtime, timer);


            var capabilityCompilation = capabilities.Compile(_handlers, Serialization, _channels, runtime, _transports, Lookup);



            var transports = _transports.Where(x => _settings.StateFor(x.Protocol) != TransportState.Disabled)
                             .ToArray();

            timer.Record("WorkersGraph.Compile", () =>
            {
                _settings.Workers.Compile(_handlers.Chains.Select(x => x.MessageType));
            });



            localWorker.Start(_persistence, Workers);

            if (!_settings.DisableAllTransports)
            {
                timer.MarkStart("ApplyLookups");

                await _settings.ApplyLookups(Lookup);

                timer.MarkFinished("ApplyLookups");


                timer.Record("ChannelGraph.Start",
                             () => { _channels.As <ChannelGraph>().Start(_settings, transports, Lookup, capabilities, Logger, Workers); });

                ScheduledJobs.Start(Workers);
            }

            runtime.Capabilities = await capabilityCompilation;
            if (runtime.Capabilities.Errors.Any() && _settings.ThrowOnValidationErrors)
            {
                throw new InvalidSubscriptionException(runtime.Capabilities.Errors);
            }

            timer.MarkFinished("ServiceBusActivator");
        }
コード例 #5
0
        private static IEnumerable<BehaviorChain> buildChains(BehaviorGraph graph)
        {
            var handlers = new HandlerGraph
            {
                HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionRequested())),
                HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionsChanged())),
                HandlerCall.For<SubscriptionsHandler>(x => x.Handle(new SubscriptionsRemoved())),
                HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TakeOwnershipRequest())),
                HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TaskHealthRequest())),
                HandlerCall.For<MonitoringControlHandler>(x => x.Handle(new TaskDeactivation()))
            };

            handlers.Compile();

            // TODO -- need to apply [ModifyChainAttribute]'s here. See GH-958

            return handlers;
        }
コード例 #6
0
        private static IEnumerable <BehaviorChain> buildChains(BehaviorGraph graph)
        {
            var handlers = new HandlerGraph
            {
                HandlerCall.For <SubscriptionsHandler>(x => x.Handle(new SubscriptionRequested())),
                HandlerCall.For <SubscriptionsHandler>(x => x.Handle(new SubscriptionsChanged())),
                HandlerCall.For <SubscriptionsHandler>(x => x.Handle(new SubscriptionsRemoved())),
                HandlerCall.For <MonitoringControlHandler>(x => x.Handle(new TakeOwnershipRequest())),
                HandlerCall.For <MonitoringControlHandler>(x => x.Handle(new TaskHealthRequest())),
                HandlerCall.For <MonitoringControlHandler>(x => x.Handle(new TaskDeactivation()))
            };


            handlers.Compile();

            // TODO -- need to apply [ModifyChainAttribute]'s here. See GH-958

            return(handlers);
        }
コード例 #7
0
        Task IFeature.Activate(JasperRuntime runtime, GenerationRules generation)
        {
            _graph.Compile(generation, runtime);

            return(runtime.Get <ServiceBusActivator>().Activate(_graph, Capabilities, runtime, _channels, _localWorker));
        }