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>(); } }); }
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>(); } }); }
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>(); }); }
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); }); }); }