Exemple #1
0
            protected override async Task Given()
            {
                _persistentSubscriptionsClient = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);

                var groupNames = new[] { "groupA", "groupB", "groupC" };

                foreach (var group in groupNames)
                {
                    await _persistentSubscriptionsClient.CreateAsync(new CreateReq {
                        Options = new CreateReq.Types.Options {
                            GroupName = group,
                            Stream    = new CreateReq.Types.StreamOptions {
                                Start            = new Empty(),
                                StreamIdentifier = new StreamIdentifier {
                                    StreamName = ByteString.CopyFromUtf8(_streamName)
                                }
                            },
                            Settings = TestPersistentSubscriptionSettings
                        }
                    }, GetCallOptions(AdminCredentials));

                    _expectedSubscriptionInfo.Add(GetSubscriptionInfoFromSettings(
                                                      TestPersistentSubscriptionSettings, group, _streamName, "0", string.Empty));
                }
            }
        public EventStorePersistentSubscriptionsClient(CallInvoker callInvoker)
        {
            if (callInvoker == null)
            {
                throw new ArgumentNullException(nameof(callInvoker));
            }

            _client = new PersistentSubscriptions.PersistentSubscriptionsClient(callInvoker);
        }
        public EventStorePersistentSubscriptionsClient(CallInvoker callInvoker, EventStoreClientSettings settings)
        {
            if (callInvoker == null)
            {
                throw new ArgumentNullException(nameof(callInvoker));
            }

            _client = new PersistentSubscriptions.PersistentSubscriptionsClient(callInvoker);
            _log    = settings.LoggerFactory?.CreateLogger <EventStorePersistentSubscriptionsClient>()
                      ?? new NullLogger <EventStorePersistentSubscriptionsClient>();
        }
Exemple #4
0
            protected override async Task Given()
            {
                _persistentSubscriptionsClient = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);

                var settings = WithoutExtraStatistics(TestPersistentSubscriptionSettings);

                await _persistentSubscriptionsClient.CreateAsync(new CreateReq {
                    Options = new CreateReq.Types.Options {
                        GroupName = _groupName,
                        Stream    = new CreateReq.Types.StreamOptions {
                            Start            = new Empty(),
                            StreamIdentifier = new StreamIdentifier {
                                StreamName = ByteString.CopyFromUtf8(_streamName)
                            }
                        },
                        Settings = settings
                    }
                }, GetCallOptions(AdminCredentials));

                // create a connection to the persistent subscription
                var call = _persistentSubscriptionsClient.Read(GetCallOptions(AdminCredentials));
                await call.RequestStream.WriteAsync(new ReadReq {
                    Options = new ReadReq.Types.Options {
                        GroupName        = _groupName,
                        StreamIdentifier = new StreamIdentifier {
                            StreamName = ByteString.CopyFromUtf8(_streamName)
                        },
                        UuidOption = new ReadReq.Types.Options.Types.UUIDOption {
                            Structured = new Empty()
                        },
                        BufferSize = 10
                    }
                });

                await call.ResponseStream.MoveNext().ConfigureAwait(false);

                Assert.IsTrue(call.ResponseStream.Current.ContentCase == ReadResp.ContentOneofCase.SubscriptionConfirmation);

                var expectedConnection = new SubscriptionInfo.Types.ConnectionInfo()
                {
                    Username       = "******",
                    AvailableSlots = 10,
                    ConnectionName = "\u003cunknown\u003e"
                };

                _expectedSubscriptionInfo = GetSubscriptionInfoFromSettings(settings,
                                                                            _groupName, _streamName, "0", string.Empty, new [] { expectedConnection });
            }
            protected override async Task Given()
            {
                _persistentSubscriptionsClient = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);

                await CreateTestPersistentSubscription(_persistentSubscriptionsClient, _streamName, _groupName, GetCallOptions(AdminCredentials));

                _subscriptionStream = await SubscribeToPersistentSubscription(
                    _persistentSubscriptionsClient, _groupName, _streamName, GetCallOptions(AdminCredentials));

                // Write events to the subscription
                var writeRes = await AppendToStreamBatch(new BatchAppendReq {
                    Options = new() {
                        Any = new(),
                        StreamIdentifier = new() { StreamName = ByteString.CopyFromUtf8(_streamName) }
                    },
                    IsFinal          = true,
                    ProposedMessages = { CreateEvents(_eventCount) },
 internal PersistentSubscription(
     PersistentSubscriptions.PersistentSubscriptionsClient client,
     ReadReq.Types.Options options,
     bool autoAck,
     Func <PersistentSubscription, ResolvedEvent, int?, CancellationToken, Task> eventAppeared,
     Action <PersistentSubscription, SubscriptionDroppedReason, Exception> subscriptionDropped,
     UserCredentials userCredentials)
 {
     _client              = client;
     _userCredentials     = userCredentials;
     _options             = options;
     _autoAck             = autoAck;
     _eventAppeared       = eventAppeared;
     _subscriptionDropped = subscriptionDropped;
     _disposed            = new CancellationTokenSource();
     _started             = new TaskCompletionSource <bool>();
     Task.Run(Start);
 }
Exemple #7
0
        public async Task can_create_persistent_subscription()
        {
            var client = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);

            var settings = new CreateReq.Types.Settings {
                CheckpointAfterMs  = 10000,
                ExtraStatistics    = true,
                MaxCheckpointCount = 20,
                MinCheckpointCount = 10,
                MaxRetryCount      = 30,
                MaxSubscriberCount = 40,
                MessageTimeoutMs   = 20000,
                HistoryBufferSize  = 60,
                LiveBufferSize     = 10,
                ReadBatchSize      = 50
            };

            if (_legacy)
            {
#pragma warning disable 612
                settings.NamedConsumerStrategy = CreateReq.Types.ConsumerStrategy.Pinned;
#pragma warning restore 612
            }
            else
            {
                settings.ConsumerStrategy = "Pinned";
            }

            await client.CreateAsync(
                new CreateReq {
                Options = new CreateReq.Types.Options {
                    GroupName = "group",
                    Stream    = new CreateReq.Types.StreamOptions {
                        Start            = new Empty(),
                        StreamIdentifier = new StreamIdentifier {
                            StreamName = ByteString.CopyFromUtf8("stream")
                        }
                    },
                    Settings = settings
                }
            },
                GetCallOptions(AdminCredentials));
        }
Exemple #8
0
            protected override async Task Given()
            {
                _persistentSubscriptionsClient = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);

                await _persistentSubscriptionsClient.CreateAsync(new CreateReq {
                    Options = new CreateReq.Types.Options {
                        GroupName = _groupName,
                        All       = new CreateReq.Types.AllOptions {
                            Start = new Empty()
                        },
                        Settings = TestPersistentSubscriptionSettings
                    }
                }, GetCallOptions(AdminCredentials));

                var events = await GetAllEvents(StreamsClient, GetCallOptions(AdminCredentials));

                var lastPosition = (long)events.Last().Event.CommitPosition;

                _expectedSubscriptionInfo =
                    GetSubscriptionInfoFromSettings(TestPersistentSubscriptionSettings, _groupName,
                                                    "$all", "C:0/P:0", $"C:{lastPosition}/P:{lastPosition}");
            }
 protected override Task Given()
 {
     _persistentSubscriptionsClient = new PersistentSubscriptions.PersistentSubscriptionsClient(Channel);
     return(Task.CompletedTask);
 }