Beispiel #1
0
 public CorrelatedStreamStoreRepository(
     IStreamNameBuilder streamNameBuilder,
     IStreamStoreConnection streamStoreConnection,
     IEventSerializer eventSerializer)
 {
     _repository = new StreamStoreRepository(streamNameBuilder, streamStoreConnection, eventSerializer);
 }
 public StreamStoreRepository(
     IStreamNameBuilder streamNameBuilder,
     IStreamStoreConnection eventStoreConnection,
     IEventSerializer eventSerializer)
 {
     _streamNameBuilder     = streamNameBuilder;
     _streamStoreConnection = eventStoreConnection;
     _eventSerializer       = eventSerializer;
 }
Beispiel #3
0
 public ConfiguredConnection(
     IStreamStoreConnection conn,
     IStreamNameBuilder namer,
     IEventSerializer serializer)
 {
     Connection  = conn;
     StreamNamer = namer;
     Serializer  = serializer;
 }
 public CorrelatedStreamStoreRepository(
     IStreamNameBuilder streamNameBuilder,
     IStreamStoreConnection streamStoreConnection,
     IEventSerializer eventSerializer,
     Func <IRepository, IAggregateCache> cacheFactory = null)
 {
     _repository = new StreamStoreRepository(streamNameBuilder, streamStoreConnection, eventSerializer);
     if (cacheFactory != null)
     {
         _cache = cacheFactory(_repository);
     }
 }
Beispiel #5
0
 public QueuedStreamListener(
     string name,
     IStreamStoreConnection connection,
     IStreamNameBuilder streamNameBuilder,
     IEventSerializer serializer,
     string busName = null,
     Action <Unit> liveProcessingStarted = null,
     Action <SubscriptionDropReason, Exception> subscriptionDropped = null) :
     base(name, connection, streamNameBuilder, serializer, busName, liveProcessingStarted, subscriptionDropped)
 {
     SyncQueue = new QueuedHandler(this, "SyncListenerQueue");
 }
        protected with_message_logging_disabled()
        {
            StreamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("UnitTest");
            EventSerializer   = new JsonMessageSerializer();
            Repo = new StreamStoreRepository(StreamNameBuilder, Connection, new JsonMessageSerializer());
            // ctor defaults to disabled
            Logging = new EventStoreMessageLogger(Bus,
                                                  Connection,
                                                  StreamName);

            Thread.Sleep(1000);
        }
 /// <summary>
 /// Create a stream Reader
 /// </summary>
 /// <param name="name">Name of the reader</param>
 /// <param name="streamStoreConnection">The stream store to subscribe to</param>
 /// <param name="streamNameBuilder">The source for correct stream names based on aggregates and events</param>
 /// <param name="serializer">the serializer to apply to the evenets in the stream</param>
 /// <param name="busName">The name to use for the internal bus (helpful in debugging)</param>
 public StreamReader(
     string name,
     IStreamStoreConnection streamStoreConnection,
     IStreamNameBuilder streamNameBuilder,
     IEventSerializer serializer,
     string busName = null)
 {
     ReaderName             = name ?? nameof(StreamReader);
     _streamStoreConnection = streamStoreConnection ?? throw new ArgumentNullException(nameof(streamStoreConnection));
     _streamNameBuilder     = streamNameBuilder ?? throw new ArgumentNullException(nameof(streamNameBuilder));
     Serializer             = serializer ?? throw new ArgumentNullException(nameof(serializer));
     Bus = new InMemoryBus(busName ?? $"{ReaderName} {nameof(EventStream)}");
 }
Beispiel #8
0
 /// <summary>
 /// Create a stream Reader
 /// </summary>
 /// <param name="name">Name of the reader</param>
 /// <param name="streamStoreConnection">The stream store to subscribe to</param>
 /// <param name="streamNameBuilder">The source for correct stream names based on aggregates and events</param>
 /// <param name="serializer">the serializer to apply to the events in the stream</param>
 /// <param name="handle">The target handle that read events are passed to</param>
 public StreamReader(
     string name,
     IStreamStoreConnection streamStoreConnection,
     IStreamNameBuilder streamNameBuilder,
     IEventSerializer serializer,
     Action <IMessage> handle)
 {
     ReaderName             = name ?? nameof(StreamReader);
     _streamStoreConnection = streamStoreConnection ?? throw new ArgumentNullException(nameof(streamStoreConnection));
     _streamNameBuilder     = streamNameBuilder ?? throw new ArgumentNullException(nameof(streamNameBuilder));
     Serializer             = serializer ?? throw new ArgumentNullException(nameof(serializer));
     Handle = handle;
 }
Beispiel #9
0
        public MockStreamStoreConnectionTests(StreamStoreConnectionFixture fixture)
        {
            _streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("UnitTest");

            var mockStreamStore = new MockStreamStoreConnection("Test");

            _streamStoreConnections.Add(mockStreamStore);
            mockStreamStore.Connect();
            _streamStoreConnections.Add(fixture.Connection);

            _repos.Add(new StreamStoreRepository(_streamNameBuilder, mockStreamStore, new JsonMessageSerializer()));

            _repos.Add(new StreamStoreRepository(_streamNameBuilder, fixture.Connection, new JsonMessageSerializer()));
        }
        /// <summary>
        /// For listening to generic streams
        /// </summary>
        /// <param name="listenerName"></param>
        /// <param name="eventStoreConnection">The event store to subscribe to</param>
        /// <param name="streamNameBuilder">The source for correct stream names based on aggregates and events</param>
        /// <param name="serializer"></param>
        /// <param name="busName">The name to use for the internal bus (helpful in debugging)</param>
        public StreamListener(
            string listenerName,
            IStreamStoreConnection eventStoreConnection,
            IStreamNameBuilder streamNameBuilder,
            IEventSerializer serializer,
            string busName = null)
        {
            _bus = new InMemoryBus(busName ?? "Stream Listener");
            _eventStoreConnection = eventStoreConnection ?? throw new ArgumentNullException(nameof(eventStoreConnection));

            ListenerName       = listenerName;
            _streamNameBuilder = streamNameBuilder;
            _serializer        = serializer;
        }
 public SynchronizableStreamListener(
     string name,
     IStreamStoreConnection connection,
     IStreamNameBuilder streamNameBuilder,
     IEventSerializer serializer,
     bool sync      = false,
     string busName = null) :
     base(name, connection, streamNameBuilder, serializer, busName)
 {
     Sync = sync;
     if (Sync)
     {
         SyncQueue = new QueuedHandler(this, "SyncListenerQueue");
     }
 }
 /// <summary>
 /// For listening to generic streams
 /// </summary>
 /// <param name="listenerName"></param>
 /// <param name="streamStoreConnection">The event store to subscribe to</param>
 /// <param name="streamNameBuilder">The source for correct stream names based on aggregates and events</param>
 /// <param name="serializer"></param>
 /// <param name="busName">The name to use for the internal bus (helpful in debugging)</param>
 /// <param name="liveProcessingStarted"></param>
 /// <param name="subscriptionDropped"></param>
 public StreamListener(
     string listenerName,
     IStreamStoreConnection streamStoreConnection,
     IStreamNameBuilder streamNameBuilder,
     IEventSerializer serializer,
     string busName = null,
     Action <Unit> liveProcessingStarted = null,
     Action <SubscriptionDropReason, Exception> subscriptionDropped = null)
 {
     Bus = new InMemoryBus(busName ?? "Stream Listener");
     _streamStoreConnection = streamStoreConnection ?? throw new ArgumentNullException(nameof(streamStoreConnection));
     Settings               = CatchUpSubscriptionSettings.Default;
     ListenerName           = listenerName;
     _streamNameBuilder     = streamNameBuilder;
     Serializer             = serializer;
     _liveProcessingStarted = liveProcessingStarted;
     _subscriptionDropped   = subscriptionDropped;
 }
        public StreamReaderTests(ITestOutputHelper toh, StreamStoreConnectionFixture fixture)
        {
            _toh = toh;
            _streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("UnitTest");
            var mockStreamStore = new MockStreamStoreConnection("Test-" + Guid.NewGuid());

            mockStreamStore.Connect();

            _stores.Add(mockStreamStore);
            _stores.Add(fixture.Connection);

            _streamName = _streamNameBuilder.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());


            foreach (var store in _stores)
            {
                AppendEvents(NUM_OF_EVENTS, store, _streamName);
            }
        }
        public StreamStoreSubscriptionTests(StreamStoreConnectionFixture fixture)
        {
            _admin             = fixture.AdminCredentials;
            _streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("UnitTest");
            var mockStreamStore = new MockStreamStoreConnection(nameof(MockStreamStoreConnection));

            mockStreamStore.Connect();
            fixture.Connection.Connect();
            _stores.Add(mockStreamStore);
            _stores.Add(fixture.Connection);

            _streamName = _streamNameBuilder.GenerateForAggregate(typeof(TestAggregate), Guid.NewGuid());
            var eventCount = 10;

            foreach (var store in _stores)
            {
                AppendEvents(eventCount, store, _streamName);
            }
        }
Beispiel #15
0
        public AccountFixture()
        {
            MainBus = new Dispatcher("Test bus");

            ConnectToLiveES();

            _streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder("upgrade");

            _getListener = name => new Model.Foundation.StreamListener(
                listenerName: name,
                eventStoreConnection: Connection,
                streamNameBuilder: _streamNameBuilder,
                serializer: new JsonMessageSerializer());

            // Build event store repository
            Repo = new StreamStoreRepository(
                streamNameBuilder: _streamNameBuilder,
                eventStoreConnection: Connection,
                eventSerializer: new JsonMessageSerializer());

            var _ = new AccountSvc(MainBus, Repo);
        }
Beispiel #16
0
 public EventStoreRepositoryIntegrationTests(StreamStoreConnectionFixture fixture)
 {
     _connection        = fixture.Connection;
     _streamNameBuilder = new PrefixedCamelCaseStreamNameBuilder(DomainPrefix);
     _repo = new StreamStoreRepository(_streamNameBuilder, _connection, new JsonMessageSerializer());
 }