Exemplo n.º 1
0
 public InMemoryEventStoreSession(IHoldAllConfiguration configuration, Dictionary <TId, ItemWithType[]> data, TId id)
     : base(configuration)
 {
     this.data      = data ?? throw new ArgumentNullException(nameof(data));
     initialVersion = data[id].Length;
     this.id        = id;
 }
Exemplo n.º 2
0
 public InMemoryEventStoreSession(IHoldAllConfiguration configuration, List <ItemWithType> stream, TId id)
     : base(configuration)
 {
     this.stream    = stream ?? throw new ArgumentNullException(nameof(stream));
     initialVersion = stream.Count;
     Id             = id;
 }
 public EventStoreRepository(IValidateState <TState> stateValidator, IHoldAllConfiguration configs, IEventStoreConnection connection, IDateTimeProvider dateTimeProvider = null)
 {
     this.stateValidator   = stateValidator ?? throw new ArgumentNullException(nameof(stateValidator));
     this.configs          = configs ?? throw new ArgumentNullException(nameof(connection));
     this.connection       = connection ?? throw new ArgumentNullException(nameof(connection));
     this.dateTimeProvider = dateTimeProvider ?? new SystemDateTimeProvider();
 }
Exemplo n.º 4
0
 public EventStoreSession(IHoldAllConfiguration configuration,
                          IEventStoreConnection eventStoreConnection,
                          string streamName,
                          IDateTimeProvider dateTimeProvider = null)
     : this(defaultValidator, configuration, eventStoreConnection, streamName, dateTimeProvider)
 {
 }
        public EventStoreReadOnlyRepository(IHoldAllConfiguration configs, EventStoreClient esClient)
        {
            new EventStoreClient(EventStoreClientSettings.Create("esdb://localhost:2113?tls=false"));
            this.configs = configs ?? throw new ArgumentNullException(nameof(configs));

            reader = new EventReader(esClient, configs);
        }
Exemplo n.º 6
0
        } = 1024;                                   //4095 is max allowed value

        public EventStoreSession(IHoldAllConfiguration configuration,
                                 IEventStoreConnection eventStoreConnection,
                                 string streamName)
            : base(configuration)
        {
            this.eventStoreConnection = eventStoreConnection ?? throw new ArgumentNullException(nameof(eventStoreConnection));
            this.streamName           = streamName ?? throw new ArgumentNullException(nameof(streamName));
        }
Exemplo n.º 7
0
 public EventStoreRepository(IValidateState <TState> stateValidator, IHoldAllConfiguration configs, EventStoreClient client, IDateTimeProvider dateTimeProvider = null)
 {
     this.stateValidator   = stateValidator ?? throw new ArgumentNullException(nameof(stateValidator));
     this.configs          = configs ?? throw new ArgumentNullException(nameof(configs));
     this.eventReader      = new EventReader(client, configs);
     this.client           = client ?? throw new ArgumentNullException(nameof(client));
     this.dateTimeProvider = dateTimeProvider ?? new SystemDateTimeProvider();
 }
Exemplo n.º 8
0
        public void Setup(IHoldAllConfiguration configuration)
        {
            if (repository != null)
            {
                throw new Exception($"{nameof(repository)} already setup");
            }

            repository = new InMemoryEventSourcedRepository <string, IHoldHigherOrder>(configuration);
        }
Exemplo n.º 9
0
 public EventStoreSession
 (
     IHoldAllConfiguration configuration,
     IReadEventsFromStream eventReader,
     IStoreEventsToStream eventWriter,
     string streamName,
     IDateTimeProvider dateTimeProvider = null
 ) : this(defaultValidator, configuration, eventReader, eventWriter, streamName, dateTimeProvider)
 {
 }
Exemplo n.º 10
0
 public static void SetupNode()
 {
     configuration = Configuration.Begin()
                     .WithDefaultCollection()
                     .WithDefaultStateFactory()
                     .NeverUseThreadSafe()
                     .WithNoEventPublisher()
                     .WithAnyAppliersFrom(Assembly.GetExecutingAssembly())
                     .AndNoMoreAppliers()
                     .WithNoUpconverters()
                     .Build();
 }
        public EventStoreSession(IValidateState <TState> stateValidator,
                                 IHoldAllConfiguration configuration,
                                 IEventStoreConnection eventStoreConnection,
                                 string streamName)
            : base(stateValidator, configuration)
        {
            this.eventStoreConnection =
                eventStoreConnection ?? throw new ArgumentNullException(nameof(eventStoreConnection));
            this.streamName = streamName ?? throw new ArgumentNullException(nameof(streamName));

            this.eventReader = new EventReader(eventStoreConnection, configuration);
        }
Exemplo n.º 12
0
 public EntityFrameworkSession(IHoldAllConfiguration configuration,
                               DbContext dbContext,
                               DbSet <TState> set,
                               bool isNew,
                               bool useStateImmutabilityWrapping = true)
     : base(configuration, dbContext)
 {
     this.isNew     = isNew;
     this.set       = set;
     this.dbContext = dbContext;
     this.useStateImmutabilityWrapping = useStateImmutabilityWrapping;
 }
Exemplo n.º 13
0
 public ConfigurationSetup(IObjectContainer objectContainer)
 {
     this.objectContainer = objectContainer;
     configuration        = Configuration.Begin()
                            .WithDefaultCollection()
                            .WithDefaultStateFactory()
                            .NeverUseThreadSafe()
                            .WithNoEventPublisher()
                            .WithAnyAppliersFrom(Assembly.GetExecutingAssembly())
                            .AndNoMoreAppliers()
                            .WithNoUpconverters()
                            .Build();
 }
        public EventStoreSession(IValidateState <TState> stateValidator,
                                 IHoldAllConfiguration configuration,
                                 EventStoreClient eventStoreClientclient,
                                 string streamName,
                                 IDateTimeProvider dateTimeProvider = null)
            : base(stateValidator, configuration)
        {
            this.client =
                eventStoreClientclient ?? throw new ArgumentNullException(nameof(eventStoreClientclient));
            this.streamName       = streamName ?? throw new ArgumentNullException(nameof(streamName));
            this.dateTimeProvider = dateTimeProvider ?? new SystemDateTimeProvider();

            this.eventReader = new EventReader(client, configuration);
        }
Exemplo n.º 15
0
        protected BaseRepoSession(IHoldAllConfiguration configuration, IDisposable disposableHandle)
        {
            this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            this.disposableHandle = disposableHandle;

            NewEventsCollection = configuration.CollectionTypeSelector(stateType)();

            currentState = default(TState);

            this.eventPublisher = configuration.EventPublisher;

            EventApplier = this.configuration.EventApplier;
        }
Exemplo n.º 16
0
        public EventStoreSession
        (
            IValidateState <TState> stateValidator,
            IHoldAllConfiguration configuration,
            IReadEventsFromStream eventReader,
            IStoreEventsToStream eventWriter,
            string streamName,
            IDateTimeProvider dateTimeProvider = null
        ) : base(stateValidator, configuration)
        {
            this.eventReader = eventReader ?? throw new ArgumentNullException(nameof(eventReader));
            this.eventWriter = eventWriter ?? throw new ArgumentNullException(nameof(eventWriter));

            this.streamName       = streamName ?? throw new ArgumentNullException(nameof(streamName));
            this.dateTimeProvider = dateTimeProvider ?? new SystemDateTimeProvider();
        }
Exemplo n.º 17
0
        private async Task PublishEvents(IHoldAllConfiguration configuration, ItemWithType[] events, CancellationToken cancellationToken = default(CancellationToken))
        {
            bool         hasInterceptors = configuration.HasInterceptors;
            ItemWithType @event;

            for (var i = 0; i < events.Length; i++)
            {
                @event = events[i];

                TryCallInterceptor(hasInterceptors, configuration.Interceptors, @event,
                                   (interc, e, et, s, st) => interc.BeforePublish(e, et, s, st));

                //We await each one to guarantee ordering of publishing, even though it would have been more performant
                // to publish and await all of them with a WhenAll
                await eventPublisher.Publish(events[i], cancellationToken);

                TryCallInterceptor(hasInterceptors, configuration.Interceptors, @event,
                                   (interc, e, et, s, st) => interc.AfterPublish(e, et, s, st));
            }
        }
Exemplo n.º 18
0
 public BaseEventSourcedSession(IHoldAllConfiguration configuration, IDisposable disposableHandle = null)
     : base(configuration, disposableHandle)
     => eventApplier = configuration.EventApplier;
 public EventReader(IEventStoreConnection connection, IHoldAllConfiguration configuration)
 {
     stateFactory         = configuration?.StateFactory ?? throw new ArgumentNullException(nameof(configuration));
     eventStoreConnection = connection ?? throw new ArgumentNullException(nameof(connection));
 }
Exemplo n.º 20
0
 public NEventStoreSession(IHoldAllConfiguration configuration, IEventStream stream)
     : base(configuration)
 {
     eventStream = stream ?? throw new ArgumentNullException(nameof(stream));
 }
Exemplo n.º 21
0
 public StubSession(IHoldAllConfiguration config, Action <string> onSave)
     : base(config, new MemoryStream())
     => OnSave = onSave;
Exemplo n.º 22
0
 public StubRepo(IHoldAllConfiguration config, ConcurrentQueue <string> calls)
 {
     OnSave        = calls.Enqueue;
     Configuration = config;
 }
Exemplo n.º 23
0
 protected BaseRepoSession(IHoldAllConfiguration configuration, IDisposable disposableHandle)
     : this(new AlwaysPassValidator <TState>(), configuration, disposableHandle)
 {
 }
Exemplo n.º 24
0
        public EventStoreReadOnlyRepository(IHoldAllConfiguration configs, IEventStoreConnection connection)
        {
            this.configs = configs ?? throw new ArgumentNullException(nameof(connection));

            reader = new EventReader(connection, configs);
        }
Exemplo n.º 25
0
 public EventStoreRepository(IHoldAllConfiguration configs, IEventStoreConnection connection)
 {
     this.configs    = configs ?? throw new ArgumentNullException(nameof(connection));
     this.connection = connection ?? throw new ArgumentNullException(nameof(connection));
 }
 public TcpEventReader(IEventStoreConnection client, IHoldAllConfiguration configuration, int pageSize = 4096)
 {
     stateFactory    = configuration?.StateFactory ?? throw new ArgumentNullException(nameof(configuration));
     this.connection = client ?? throw new ArgumentNullException(nameof(client));
     this.pageSize   = pageSize;
 }
Exemplo n.º 27
0
 public BaseEventSourcedSession(IValidateState <TState> validator, IHoldAllConfiguration configuration, IDisposable disposableHandle = null)
     : base(validator, configuration, disposableHandle)
     => eventApplier = configuration.EventApplier;
 public void SetupRepository(IHoldAllConfiguration configuration)
 {
     repository = new EventStoreRepository <string, IHoldHigherOrder>(configuration, GetConnection());
 }
Exemplo n.º 29
0
 public EventStoreReadOnlyRepository(IHoldAllConfiguration configs, IReadEventsFromStream reader)
 {
     this.configs = configs ?? throw new ArgumentNullException(nameof(configs));
     this.reader  = reader;
 }
Exemplo n.º 30
0
 public static SerializationWireup WithSerializationForInterfaceMessages(
     this PersistenceWireup persistenceWireup,
     IHoldAllConfiguration configuration)
 => persistenceWireup.UsingCustomSerialization(new CustomSerializer(configuration));