Exemplo n.º 1
0
 public EventStoreIndicesStartup(TypeContainer <IEventStoreIndex> indexTypeContainer, IOptions <CronusHostOptions> cronusHostOptions, IOptionsMonitor <TenantsOptions> tenantsOptions, IPublisher <ICommand> publisher)
 {
     this.tenants            = tenantsOptions.CurrentValue;
     this.publisher          = publisher;
     this.indexTypeContainer = indexTypeContainer;
     this.cronusHostOptions  = cronusHostOptions.Value;
 }
Exemplo n.º 2
0
 private void Stop(CronusHostOptions oldOptions, CronusHostOptions newOptions)
 {
     try
     {
         if (oldOptions.ApplicationServicesEnabled == true && newOptions.ApplicationServicesEnabled == false)
         {
             appServices.Stop();
         }
         if (oldOptions.SagasEnabled == true && newOptions.SagasEnabled == false)
         {
             sagas.Stop();
         }
         if (oldOptions.ProjectionsEnabled == true && newOptions.ProjectionsEnabled == false)
         {
             projections.Stop();
         }
         if (oldOptions.PortsEnabled == true && newOptions.PortsEnabled == false)
         {
             ports.Stop();
         }
         if (oldOptions.GatewaysEnabled == true && newOptions.GatewaysEnabled == false)
         {
             gateways.Stop();
         }
     }
     catch (Exception ex)
     {
         logger.CriticalException(ex, () => $"Restop: {ex.Message}");
         throw;
     }
 }
Exemplo n.º 3
0
 public ProjectionsStartup(TypeContainer <IProjection> handlerTypeContainer, IOptions <CronusHostOptions> cronusHostOptions, IOptions <TenantsOptions> tenantsOptions, ProjectionHasher hasher, IPublisher <ICommand> publisher)
 {
     this.tenants              = tenantsOptions.Value;
     this.hasher               = hasher;
     this.publisher            = publisher;
     this.handlerTypeContainer = handlerTypeContainer;
     this.cronusHostOptions    = cronusHostOptions.Value;
 }
Exemplo n.º 4
0
        public CronusHost(ProjectionsBooter projectionsBoot, IConsumer <IApplicationService> appServices, IConsumer <IProjection> projections, IConsumer <IPort> ports, IConsumer <ISaga> sagas, IConsumer <IGateway> gateways, CronusHostOptions cronusHostOptions)
        {
            this.appServices = appServices ?? throw new ArgumentNullException(nameof(appServices));
            this.projections = projections ?? throw new ArgumentNullException(nameof(projections));
            this.ports       = ports ?? throw new ArgumentNullException(nameof(ports));
            this.sagas       = sagas ?? throw new ArgumentNullException(nameof(sagas));
            this.gateways    = gateways ?? throw new ArgumentNullException(nameof(gateways));

            this.projectionsBoot   = projectionsBoot;
            this.cronusHostOptions = cronusHostOptions;
        }
Exemplo n.º 5
0
        public CronusHost(IConsumer <IApplicationService> appServices, IConsumer <IEventStoreIndex> indexes, IConsumer <IProjection> projections, IConsumer <IPort> ports, IConsumer <ISaga> sagas, IConsumer <IGateway> gateways, IOptionsMonitor <CronusHostOptions> cronusHostOptions)
        {
            this.appServices = appServices ?? throw new ArgumentNullException(nameof(appServices));
            this.indexes     = indexes;
            this.projections = projections ?? throw new ArgumentNullException(nameof(projections));
            this.ports       = ports ?? throw new ArgumentNullException(nameof(ports));
            this.sagas       = sagas ?? throw new ArgumentNullException(nameof(sagas));
            this.gateways    = gateways ?? throw new ArgumentNullException(nameof(gateways));

            this.hostOptions = cronusHostOptions.CurrentValue;
            cronusHostOptions.OnChange(Changed);
        }
Exemplo n.º 6
0
        private void Changed(CronusHostOptions newOptions)
        {
            if (hostOptions != newOptions)
            {
                logger.Debug(() => "Cronus host options re-loaded with {@options}", newOptions);

                Start(hostOptions, newOptions);
                Stop(hostOptions, newOptions);

                hostOptions = newOptions;
            }
        }
Exemplo n.º 7
0
 private void Start(CronusHostOptions oldOptions, CronusHostOptions newOptions)
 {
     try
     {
         if (oldOptions.ApplicationServicesEnabled == false && newOptions.ApplicationServicesEnabled == true) appServices.Start();
         if (oldOptions.SagasEnabled == false && newOptions.SagasEnabled == true) sagas.Start();
         if (oldOptions.ProjectionsEnabled == false && newOptions.ProjectionsEnabled == true) projections.Start();
         if (oldOptions.PortsEnabled == false && newOptions.PortsEnabled == true) ports.Start();
         if (oldOptions.GatewaysEnabled == false && newOptions.GatewaysEnabled == true) gateways.Start();
         if (oldOptions.TriggersEnabled == false && newOptions.TriggersEnabled == true) gateways.Start();
         if (oldOptions.RpcApiEnabled == false && newOptions.RpcApiEnabled == true) rpcHost.Start();
     }
     catch (Exception ex)
     {
         logger.CriticalException(ex, () => $"Restart: {ex.Message}");
         throw;
     }
 }
Exemplo n.º 8
0
 public CronusHost(
     CronusBooter booter,
     IConsumer<IApplicationService> appServices,
     IConsumer<ICronusEventStoreIndex> systemIndices,
     IConsumer<IEventStoreIndex> indices,
     IConsumer<IProjection> projections,
     IConsumer<IPort> ports,
     IConsumer<ISaga> sagas,
     IConsumer<IGateway> gateways,
     IConsumer<ITrigger> triggers,
     IConsumer<ISystemAppService> systemAppServices,
     IConsumer<ISystemSaga> systemSagas,
     IConsumer<ISystemPort> systemPorts,
     IConsumer<ISystemTrigger> systemTriggers,
     IConsumer<ISystemProjection> systemProjections,
     IConsumer<IMigrationHandler> migrations,
     IOptionsMonitor<CronusHostOptions> cronusHostOptions,
     IServiceProvider serviceProvider, IRpcHost rpcHost)
 {
     this.booter = booter;
     this.appServices = appServices ?? throw new ArgumentNullException(nameof(appServices));
     this.systemIndices = systemIndices;
     this.indices = indices;
     this.projections = projections ?? throw new ArgumentNullException(nameof(projections));
     this.ports = ports ?? throw new ArgumentNullException(nameof(ports));
     this.sagas = sagas ?? throw new ArgumentNullException(nameof(sagas));
     this.gateways = gateways ?? throw new ArgumentNullException(nameof(gateways));
     this.triggers = triggers;
     this.systemAppServices = systemAppServices;
     this.systemSagas = systemSagas;
     this.systemPorts = systemPorts;
     this.systemTriggers = systemTriggers;
     this.systemProjections = systemProjections;
     this.migrations = migrations;
     this.serviceProvider = serviceProvider;
     this.rpcHost = rpcHost;
     this.hostOptions = cronusHostOptions.CurrentValue;
     cronusHostOptions.OnChange(Changed);
 }