Beispiel #1
0
        private static async Task SubscribeToFiltered(EventStoreClient client)
        {
            #region stream-prefix-filtered-subscription
            var prefixStreamFilter = new SubscriptionFilterOptions(StreamFilter.Prefix("test-", "other-"));
            await client.SubscribeToAllAsync(
                EventAppeared,
                filterOptions : prefixStreamFilter);

            #endregion stream-prefix-filtered-subscription

            #region stream-regex-filtered-subscription
            var regexStreamFilter = StreamFilter.RegularExpression(@"/invoice-\d\d\d/g");
            #endregion stream-regex-filtered-subscription
        }
        private static async Task StreamRegex(EventStoreClient client)
        {
            #region stream-regex
            var filter = new SubscriptionFilterOptions(
                StreamFilter.RegularExpression("^account|^savings"));
            #endregion stream-regex

            await client.SubscribeToAllAsync(Position.Start,
                                             (s, e, c) => {
                Console.WriteLine(
                    $"{e.Event.EventType} @ {e.Event.Position.PreparePosition}");
                return(Task.CompletedTask);
            },
                                             filterOptions : filter
                                             );
        }
        public async Task regular_expression_stream_name()
        {
            var streamPrefix = _fixture.GetStreamName();
            var events       = _fixture.CreateTestEvents(10).ToArray();

            foreach (var e in events)
            {
                await _fixture.Client.AppendToStreamAsync($"{streamPrefix}_{Guid.NewGuid():n}",
                                                          AnyStreamRevision.NoStream, new[] { e });
            }

            var result = await _fixture.Client.ReadAllAsync(Direction.Backwards, Position.End, 20,
                                                            filterOptions : new FilterOptions(StreamFilter.RegularExpression($"^{streamPrefix}")))
                         .ToArrayAsync();

            Assert.Equal(events.Select(x => x.EventId), result.Reverse().Select(x => x.OriginalEvent.EventId));
        }
Beispiel #4
0
 public async Task SubscribeAll_StreamFilterExpression()
 {
     var prefixStreamFilter = new SubscriptionFilterOptions(StreamFilter.RegularExpression("^test|^other"));
     await _client.SubscribeToAllAsync(SubscribeReturn,
                                       filterOptions : prefixStreamFilter);
 }