Example #1
0
        public static IDomainBuilder AddRing(this IDomainBuilder builder, IConfiguration configuration)
        {
            builder.Services.AddMemoryCache();

            builder.AddDomainCore();
            builder.AddRingOptions(configuration);

            builder.Services.TryAdd(new ServiceCollection()
                                    .AddSingleton <ICommandBus, RingCommandBus>()
                                    .AddSingleton <IEventBus, RingEventBus>()
                                    .AddSingleton <IContextCache, RingContextMemoryCache>()
                                    .AddSingleton <ISnapshootCache, SnapshootMemoryCache>()
                                    .AddSingleton <IEventHandleSubject, EventHandleSubject>()
                                    .AddSingleton <IRingBufferProcess, RingBufferProcess>()
                                    );

            builder.Services.Add(new ServiceCollection()
                                 .AddTransient <IHostedService, RingBufferServerHostedService>()
                                 );

            //IEventBus


            return(builder);
        }