Ejemplo n.º 1
0
        public CassandraEventStoreFactory(Pipeline.Config.ISettingsBuilder builder, ICassandraEventStoreSettings settings, ITenantList tenants)
        {
            if (ReferenceEquals(null, builder) == true)
            {
                throw new ArgumentNullException(nameof(builder));
            }
            if (ReferenceEquals(null, settings) == true)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            this.settings     = settings;
            this.tenants      = tenants;
            this.builder      = builder;
            tenantStores      = new Dictionary <string, IEventStore>();
            tenantPlayers     = new Dictionary <string, IEventStorePlayer>();
            hasTenantsDefined = tenants.GetTenants().Count() > 1 || (tenants.GetTenants().Count() == 1 && tenants.GetTenants().Any(t => t.Equals(CronusAssembly.EldersTenant) == false));
            if (hasTenantsDefined)
            {
                foreach (var tenant in tenants.GetTenants())
                {
                    InitializeTenant(tenant);
                }
            }
            else
            {
                InitializeTenant(NoTenantName);
            }
        }
Ejemplo n.º 2
0
 public void Bootstrap()
 {
     foreach (var tenant in tenants.GetTenants())
     {
         using (var scope = serviceProvider.CreateScope())
         {
             CronusContext context = scope.ServiceProvider.GetRequiredService <CronusContext>();
             context.Initialize(tenant, scope.ServiceProvider);
             scope.ServiceProvider.GetRequiredService <ICassandraEventStoreSchema>().CreateStorage();
         }
     }
 }
Ejemplo n.º 3
0
 public void Bootstrap()
 {
     foreach (var handler in handlerTypeContainer.Items)
     {
         foreach (var tenant in tenants.GetTenants())
         {
             var id      = new ProjectionVersionManagerId(handler.GetContractId(), tenant);
             var command = new RegisterProjection(id, hasher.CalculateHash(handler));
             publisher.Publish(command);
         }
     }
 }
Ejemplo n.º 4
0
        public ClientTenantsIncludingElders(ITenantList clientTenants = null)
        {
            if (ReferenceEquals(null, clientTenants))
            {
                tenants = new List <string>();
            }
            else
            {
                this.tenants = new List <string>(clientTenants.GetTenants());
            }

            this.tenants.Add(CronusAssembly.EldersTenant);
        }
Ejemplo n.º 5
0
        public void Bootstrap()
        {
            var systemProjection = typeof(ISystemProjection);

            foreach (var handler in handlerTypeContainer.Items.OrderByDescending(x => systemProjection.IsAssignableFrom(x)))
            {
                foreach (var tenant in tenants.GetTenants())
                {
                    var id      = new ProjectionVersionManagerId(handler.GetContractId(), tenant);
                    var command = new RegisterProjection(id, hasher.CalculateHash(handler));
                    publisher.Publish(command);
                }
            }
        }
Ejemplo n.º 6
0
        private void EnsureValidTenant(string tenant)
        {
            if (string.IsNullOrEmpty(tenant))
            {
                throw new ArgumentNullException(nameof(tenant));
            }

            ITenantList tenants = ServiceProvider.GetRequiredService <ITenantList>();

            if (tenants.GetTenants().Where(t => t.Equals(tenant, StringComparison.OrdinalIgnoreCase)).Any() == false)
            {
                throw new ArgumentException($"The tenant `{tenant}` is not registered. Make sure that the tenant `{tenant}` is properly configured using `cronus_tenants`. More info at https://github.com/Elders/Cronus/blob/master/doc/Configuration.md", nameof(tenant));
            }
        }