public static IWebHostBuilder UseJasper(this IWebHostBuilder builder, Action <JasperOptionsBuilder> overrides)
        {
            var registry = new JasperOptionsBuilder();

            overrides?.Invoke(registry);
            return(builder.UseJasper(registry));
        }
示例#2
0
        internal JasperRuntime(IWebHost host)
        {
            _host     = host;
            _registry = host.Services.GetRequiredService <JasperOptionsBuilder>();
            Container = host.Services.GetService <IContainer>();

            Container.As <Container>().Configure(x => x.AddSingleton(this));

            _bus = new Lazy <IMessageContext>(Get <IMessageContext>);
        }
        private void aspnetcore(JasperOptionsBuilder parent)
        {
            this.AddSingleton <ConnegRules>();

            this.AddScoped <IHttpContextAccessor>(x => new HttpContextAccessor());
            this.AddSingleton(parent.HttpRoutes.Routes.Router);
            this.AddSingleton(parent.HttpRoutes.Routes);
            ForSingletonOf <IUrlRegistry>().Use(parent.HttpRoutes.Routes.Router.Urls);

            this.AddSingleton <IServiceProviderFactory <IServiceCollection> >(new DefaultServiceProviderFactory());
        }
        private void conneg(JasperOptionsBuilder parent)
        {
            this.AddOptions();

            var forwarding = new Forwarders();

            For <Forwarders>().Use(forwarding);

            Scan(_ =>
            {
                _.Assembly(parent.ApplicationAssembly);
                _.AddAllTypesOf <IMessageSerializer>();
                _.AddAllTypesOf <IMessageDeserializer>();
                _.With(new ForwardingRegistration(forwarding));
            });
        }
        public JasperServiceRegistry(JasperOptionsBuilder parent)
        {
            For <IMetrics>().Use <NulloMetrics>();
            For <IHostedService>().Use <MetricsCollector>();

            this.AddLogging();

            For <IMessageLogger>().Use <MessageLogger>().Singleton();
            For <ITransportLogger>().Use <TransportLogger>().Singleton();


            this.AddSingleton(parent.CodeGeneration);

            For <IHostedService>().Use <BackPressureAgent>();

            conneg(parent);
            messaging(parent);

            aspnetcore(parent);
        }
        private void messaging(JasperOptionsBuilder parent)
        {
            ForSingletonOf <MessagingSerializationGraph>().Use <MessagingSerializationGraph>();

            For <IEnvelopePersistor>().Use <NulloEnvelopePersistor>();
            this.AddSingleton <InMemorySagaPersistor>();

            this.AddSingleton(parent.Messaging.Graph);
            this.AddSingleton <ISubscriberGraph>(parent.Messaging.Subscribers);
            this.AddSingleton <ILocalWorkerSender>(parent.Messaging.LocalWorker);

            this.AddSingleton <IRetries, EnvelopeRetries>();

            For <ITransport>()
            .Use <LoopbackTransport>();

            For <ITransport>()
            .Use <TcpTransport>();


            ForSingletonOf <IMessagingRoot>().Use <MessagingRoot>();

            ForSingletonOf <ObjectPoolProvider>().Use(new DefaultObjectPoolProvider());


            MessagingRootService(x => x.Workers);
            MessagingRootService(x => x.Pipeline);

            MessagingRootService(x => x.Router);
            MessagingRootService(x => x.ScheduledJobs);

            For <IMessageContext>().Use(new MessageContextInstance());

            ForSingletonOf <ITransportLogger>().Use <TransportLogger>();

            For <IEnvironmentRecorder>().Use <EnvironmentRecorder>();
        }
        public static IWebHostBuilder UseJasper(this IWebHostBuilder builder, JasperOptionsBuilder jasperBuilder)
        {
            JasperRuntime.ApplyExtensions(jasperBuilder);

            jasperBuilder.HttpRoutes.StartFindingRoutes(jasperBuilder.ApplicationAssembly);
            jasperBuilder.Messaging.StartCompiling(jasperBuilder);

            jasperBuilder.Settings.Apply(jasperBuilder.Services);

            builder.ConfigureServices(s =>
            {
                s.AddSingleton <IHostedService, JasperActivator>();

                s.AddRange(jasperBuilder.CombineServices());
                s.AddSingleton(jasperBuilder);

                s.AddSingleton <IServiceProviderFactory <ServiceRegistry>, LamarServiceProviderFactory>();
                s.AddSingleton <IServiceProviderFactory <IServiceCollection>, LamarServiceProviderFactory>();

                s.AddSingleton <IStartupFilter>(new RegisterJasperStartupFilter());
            });

            return(builder);
        }
 public JasperActivator(JasperOptionsBuilder registry, IMessagingRoot root, IContainer container)
 {
     _registry  = registry;
     _root      = root;
     _container = container;
 }