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));
                }
            }
Exemple #2
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 });
            }
Exemple #3
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 #4
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}");
            }