Пример #1
0
        private IPublisher <TMessage> CreatePublisher <TMessage>(IPublisherConfiguration <TMessage> configuration)
        {
            logger.DebugFormat("Creating publisher for {0} with configuration {1}",
                               typeof(TMessage).Name,
                               configuration);

            var model = modelFactory.CreateModel();

            return(publisherFactory.Create(model, configuration));
        }
Пример #2
0
        public EventStoreSettings Build(
            DbConnections connections,
            IPublisherFactory publisherFactory,
            IEventSerializer eventSerializer)
        {
            if (connections == null)
            {
                throw new ArgumentNullException(nameof(connections));
            }

            if (publisherFactory == null)
            {
                throw new ArgumentNullException(nameof(publisherFactory));
            }

            if (eventSerializer == null)
            {
                throw new ArgumentNullException(nameof(eventSerializer));
            }

            var contexts = new Dictionary <string, IEventStoreContext>();

            _aggregates.ForEach(a =>
            {
                if (a.Partitions > 1)
                {
                    var(type, context) = CreateCategoryType(a.Type, a.Partitions, publisherFactory.Create(a.Topic));
                    contexts.Add(type, context);
                }

                else
                {
                    var(type, context) = CreateCategoryType(a.Type, publisherFactory.Create(a.Topic));
                    contexts.Add(type, context);
                }
            });

            var storeSettings      = new StoreSettings(connections, contexts, eventSerializer);
            var aggregateFactories = _aggregates.ToDictionary(k => k.FactoryType, v => v.Factory);

            return(new EventStoreSettings(storeSettings, aggregateFactories));
        }