Beispiel #1
0
            public async Task <IReadOnlyList <CounterSummary> > GetCountersByPrefix(string groupName, string counterNamePrefix = null, int skip = 0, int take = 1024, CancellationToken token = default(CancellationToken))
            {
                if (string.IsNullOrWhiteSpace(groupName))
                {
                    throw new ArgumentNullException(nameof(groupName));
                }

                parent.AssertInitialized();
                await parent.ReplicationInformer.UpdateReplicationInformationIfNeededAsync().ConfigureAwait(false);

                var summaries = await parent.ReplicationInformer.ExecuteWithReplicationAsync(parent.Url, HttpMethods.Get, async (url, counterStoreName) =>
                {
                    var requestUriString = $"{url}/cs/{counterStoreName}/by-prefix?skip={skip}&take={take}&groupName={groupName}";
                    if (!string.IsNullOrWhiteSpace(counterNamePrefix))
                    {
                        requestUriString += $"&counterNamePrefix={counterNamePrefix}";
                    }

                    using (var request = parent.CreateHttpJsonRequest(requestUriString, HttpMethods.Get))
                    {
                        var response = await request.ReadResponseJsonAsync().WithCancellation(token).ConfigureAwait(false);
                        return(response.ToObject <List <CounterSummary> >());
                    }
                }, token).ConfigureAwait(false);

                return(summaries);
            }
Beispiel #2
0
            public async Task <IReadOnlyList <CounterNameGroupPair> > GetCounterStorageNameAndGroups(string counterStorageName = null,
                                                                                                     CancellationToken token   = default(CancellationToken),
                                                                                                     int skip = 0, int take = 1024)
            {
                parent.AssertInitialized();

                var requestUriString = $"{parent.Url}/admin/cs/{counterStorageName ?? parent.Name}?op=groups-names&skip={skip}&take={take}";

                using (var request = parent.CreateHttpJsonRequest(requestUriString, HttpMethods.Get))
                {
                    var response = await request.ReadResponseJsonAsync().WithCancellation(token).ConfigureAwait(false);

                    return(response.ToObject <List <CounterNameGroupPair> >(parent.JsonSerializer));
                }
            }
            public async Task FlushAsync()
            {
                if (string.IsNullOrWhiteSpace(parent.Name))
                {
                    throw new InvalidOperationException("Default counter storage name cannot be empty!");
                }

                parent.AssertInitialized();

                await parent.ReplicationInformer.UpdateReplicationInformationIfNeededAsync().ConfigureAwait(false);

                await defaultBatchOperation.Value.FlushAsync().ConfigureAwait(false);
            }