public static OzzyNodeOptionsBuilder <TDomain> UseRedisMonitoring <TDomain>(this OzzyNodeOptionsBuilder <TDomain> builder) where TDomain : IOzzyDomainModel { //todo : fix //builder.Services.AddSingleton<MonitoringEventsProcessor>(); //builder.Services.AddSingleton<IDomainEventsProcessor, MonitoringEventsProcessor>(); builder.Services.AddSingleton <INodesManager, NodesManager>(); builder.Services.AddSingleton <IMonitoringRepository, RedisMonitoringRepository>(); builder.AddBackgroundProcess <NodesMonitoringProcess>(); return(builder); }
public static void AddOzzyNode <TDomain>(this IServiceCollection services, Action <OzzyNodeOptionsBuilder <TDomain> > configureOptions) where TDomain : IOzzyDomainModel { var builder = new OzzyNodeOptionsBuilder <TDomain>(services); configureOptions(builder); if (!services.IsServiceRegistered <IQueueRepository>()) { if (services.IsTypeSpecificServiceRegistered <TDomain, IQueueRepository>()) { services.AddSingleton(sp => sp.GetTypeSpecificService <TDomain, IQueueRepository>()); } else { //TODO: throw as IQueueRepository is required; } } if (!services.IsServiceRegistered <IDistributedLockService>()) { if (services.IsTypeSpecificServiceRegistered <TDomain, IDistributedLockService>()) { services.AddSingleton(sp => sp.GetTypeSpecificService <TDomain, IDistributedLockService>()); } else { //TODO: throw as IDistributedLockService is required; } } services.TryAddSingleton <OzzyNode>(); //TODO : better handle service dependencies... E.g. we can check is queue repository is registered and do not register JobQueues if not or throw... Same for FeatureFlags and else. services.TryAddSingleton(typeof(JobQueue <>)); services.TryAddSingleton <IFeatureFlagService, FeatureFlagService>(); services.TryAddSingleton <IDomainEventsFaultHandler, DoNothingFaultHandler>(); services.AddTransient <RetryEventTask>(); services.AddSingleton(typeof(JobQueue <>)); services.AddSingleton <SagaCorrelationsMapper>(); services.AddSingleton <QueuesFaultManager>(); builder.AddBackgroundProcess <QueueTimeoutBackgroundProcess>(); }
public static OzzyNodeOptionsBuilder <TDomain> UseEFFeatureFlagService <TDomain>(this OzzyNodeOptionsBuilder <TDomain> builder) where TDomain : AggregateDbContext { builder.Services.AddSingleton <IFeatureFlagRepository>(sp => new EfFeatureFlagRepository(sp.GetService <Func <TDomain> >(), db => db.FeatureFlags)); builder.Services.AddTypeSpecificSingleton <FeatureFlag, ICheckpointManager>(sp => new EfCheckpointManager <TDomain>(sp.GetService <Func <TDomain> >(), "featureflags", -1)); builder.Services.AddSingleton <FeatureFlagsEventsProcessor>(); builder.Services.AddTypeSpecificSingleton <IDomainEventsProcessor, FeatureFlagsEventsProcessor>(); return(builder); }
public static OzzyNodeOptionsBuilder <TDomain> UseSqlServerQueues <TDomain>(this OzzyNodeOptionsBuilder <TDomain> builder) where TDomain : AggregateDbContext { builder.Services.TryAddSingleton <IQueueRepository>(sp => new SqlServerEfQueueRepository(sp.GetService <Func <TDomain> >(), db => db.Queues, db => db.DeadLetters)); return(builder); }
public static OzzyNodeOptionsBuilder <TDomain> UseEFDistributedLockService <TDomain>(this OzzyNodeOptionsBuilder <TDomain> builder) where TDomain : AggregateDbContext { builder.Services.TryAddSingleton <IDistributedLockService>(sp => new EfDistributedLockService(sp.GetService <Func <TDomain> >())); return(builder); }