コード例 #1
0
ファイル: Program.cs プロジェクト: ocoanet/Zebus
        private static void InjectDirectoryServiceSpecificConfiguration(BusFactory busFactory, string storageType)
        {
            var useCassandraStorage = string.Equals(storageType, "Cassandra", StringComparison.OrdinalIgnoreCase);

            busFactory.ConfigureContainer(c =>
            {
                c.AddRegistry <DirectoryRegistry>();
                c.ForSingletonOf <IDirectoryConfiguration>().Use <AppSettingsDirectoryConfiguration>();

                c.For <IDeadPeerDetector>().Use <DeadPeerDetector>();
                c.ForSingletonOf <IPeerRepository>().Use(ctx => useCassandraStorage ? (IPeerRepository)ctx.GetInstance <CqlPeerRepository>() : ctx.GetInstance <MemoryPeerRepository>());
                c.ForSingletonOf <PeerDirectoryServer>().Use <PeerDirectoryServer>();
                c.ForSingletonOf <IPeerDirectory>().Use(ctx => ctx.GetInstance <PeerDirectoryServer>());

                c.ForSingletonOf <IMessageDispatcher>().Use(typeof(Func <IContext, MessageDispatcher>).Name, ctx =>
                {
                    var dispatcher = ctx.GetInstance <MessageDispatcher>();
                    dispatcher.ConfigureHandlerFilter(x => x != typeof(PeerDirectoryClient));

                    return(dispatcher);
                });

                // Cassandra specific
                if (useCassandraStorage)
                {
                    c.ForSingletonOf <CassandraCqlSessionManager>().Use(() => new CassandraCqlSessionManager());
                    c.ForSingletonOf <ICassandraConfiguration>().Use <CassandraAppSettingsConfiguration>();
                }
            });
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: redchew-fork/Zebus
        private static void InjectDirectoryServiceSpecificConfiguration(BusFactory busFactory, StorageType storageType)
        {
            busFactory.ConfigureContainer(c =>
            {
                c.AddRegistry <DirectoryRegistry>();
                c.ForSingletonOf <IDirectoryConfiguration>().Use <AppSettingsDirectoryConfiguration>();

                c.For <IDeadPeerDetector>().Use <DeadPeerDetector>();
                c.ForSingletonOf <IPeerRepository>().Use(ctx => GetPeerRepository(storageType, ctx));
                c.ForSingletonOf <PeerDirectoryServer>().Use <PeerDirectoryServer>();
                c.ForSingletonOf <IPeerDirectory>().Use(ctx => ctx.GetInstance <PeerDirectoryServer>());

                c.ForSingletonOf <IMessageDispatcher>().Use(typeof(Func <IContext, MessageDispatcher>).Name,
                                                            ctx =>
                {
                    var dispatcher = ctx.GetInstance <MessageDispatcher>();
                    dispatcher.ConfigureHandlerFilter(x => x != typeof(PeerDirectoryClient));

                    return(dispatcher);
                });

                // Cassandra specific
                if (storageType == StorageType.Cassandra)
                {
                    c.ForSingletonOf <CassandraCqlSessionManager>().Use(() => new CassandraCqlSessionManager());
                    c.ForSingletonOf <ICassandraConfiguration>().Use <CassandraAppSettingsConfiguration>();
                }
            });
        }
コード例 #3
0
        private static void InjectPersistenceServiceSpecificConfiguration(BusFactory busFactory, AppSettingsConfiguration configuration)
        {
            busFactory.ConfigureContainer(c =>
            {
                c.ForSingletonOf <IPersistenceConfiguration>().Use(configuration);

                // TODO: Add InMemoryStorage
                c.ForSingletonOf <IStorage>().Use <CqlStorage>();

                c.ForSingletonOf <IMessageReplayerRepository>().Use <MessageReplayerRepository>();
                c.ForSingletonOf <IMessageReplayer>().Use <MessageReplayer>();

                c.ForSingletonOf <IMessageDispatcher>().Use(typeof(Func <IContext, MessageDispatcher>).Name,
                                                            ctx =>
                {
                    var dispatcher = ctx.GetInstance <MessageDispatcher>();
                    dispatcher.ConfigureHandlerFilter(x => x != typeof(PeerDirectoryClient));

                    return(dispatcher);
                });

                c.ForSingletonOf <ITransport>().Use <QueueingTransport>().Ctor <ITransport>().Is <ZmqTransport>();
                c.ForSingletonOf <IInMemoryMessageMatcher>().Use <InMemoryMessageMatcher>();
                c.Forward <IInMemoryMessageMatcher, IProvideQueueLength>();
                c.ForSingletonOf <IStoppingStrategy>().Use <PersistenceStoppingStrategy>();

                c.ForSingletonOf <IReporter>().Use <NoopReporter>();

                // Cassandra specific
                c.ForSingletonOf <PeerStateRepository>().Use <PeerStateRepository>();
                c.ForSingletonOf <CassandraCqlSessionManager>().Use(() => CassandraCqlSessionManager.Create());
                c.Forward <PeerStateRepository, IPeerStateRepository>();
                c.ForSingletonOf <ICqlPersistenceConfiguration>().Use <CassandraAppSettingsConfiguration>();
            });
        }
コード例 #4
0
        private static void InjectDirectoryServiceSpecificConfiguration(BusFactory busFactory)
        {
            busFactory.ConfigureContainer(c =>
            {
                c.AddRegistry <DirectoryRegistry>();
                c.ForSingletonOf <IDirectoryConfiguration>().Use <AppSettingsDirectoryConfiguration>();

                c.For <IDeadPeerDetector>().Use <DeadPeerDetector>();
                c.ForSingletonOf <IPeerRepository>().Use <MemoryPeerRepository>();
                c.ForSingletonOf <PeerDirectoryServer>().Use <PeerDirectoryServer>();
                c.ForSingletonOf <IPeerDirectory>().Use(ctx => ctx.GetInstance <PeerDirectoryServer>());

                c.ForSingletonOf <IMessageDispatcher>().Use(typeof(Func <IContext, MessageDispatcher>).Name, ctx =>
                {
                    var dispatcher = ctx.GetInstance <MessageDispatcher>();
                    dispatcher.ConfigureHandlerFilter(x => x != typeof(PeerDirectoryClient));

                    return(dispatcher);
                });
            });
        }