Beispiel #1
0
        public static void Attach(IDatabaseSystem system, ILogger logger, IEventTransformer transformer)
        {
            if (system == null)
            {
                throw new ArgumentNullException(nameof(system));
            }
            if (!(system is IEventHandler))
            {
                throw new ArgumentException("The database system is not handling events");
            }

            ((IEventHandler)system).Consume(@event => {
                try {
                    var entry = transformer?.Transform(@event);
                    if (entry == null)
                    {
                        throw new LogException("It was not possible to generate a log entry from an event");
                    }

                    if (logger.IsInterestedIn(entry.Level))
                    {
                        logger.LogAsync(entry).ConfigureAwait(false).GetAwaiter().GetResult();
                    }
                } catch (LogException) {
                    throw;
                } catch (Exception ex) {
                    throw new LogException("An error occurred while logging an event", ex);
                }
            });
        }
Beispiel #2
0
 public EventSubscriber(IEventStoreConnection connection, UserCredentials creds, string streamName,
                        IEventTransformer transformer)
 {
     this.connection  = connection;
     this.creds       = creds;
     StreamName       = streamName;
     this.transformer = transformer;
 }
Beispiel #3
0
 public BatchReader(IEventStoreConnection connection, IEventTransformer transformer, int batchSize)
 {
     this.connection  = connection;
     this.batchSize   = batchSize;
     eventTransformer = transformer;
 }
Beispiel #4
0
 public EventStoreReader(IEventStoreConnection connection, IEventTransformer transformer)
 {
     this.connection  = connection;
     eventTransformer = transformer;
     batchReader      = new BatchReader(connection, transformer, 10);
 }
Beispiel #5
0
 public EventStoreWriter(IEventStoreConnection connection, IEventTransformer transformer)
 {
     this.connection  = connection;
     this.transformer = transformer;
 }
 protected BatchReader GivenSut(IEventStoreConnection connection, IEventTransformer transformer)
 {
     return(new BatchReader(connection, transformer, batchSize));
 }