Esempio n. 1
0
        private async Task <IEnumerable <Message> > getCrossShard(LogChronicleFilter filter)
        {
            filter.CrossShard = false; //stop recursion, each shard should return just its own data
            var shards = m_Server.GetEndpointsForAllShards(LogServiceAddress, nameof(ILogChronicle));

            var calls = shards.Select(shard => shard.Call((http, ct) => http.Client.PostAndGetJsonMapAsync("filter", filter)));

            var responses = await Task.WhenAll(calls.Select(async call => {
                try
                {
                    return(await call);
                }
                catch (Exception error)
                {
                    WriteLog(MessageType.Warning, nameof(getCrossShard), "Shard fetch error: " + error.ToMessageWithType(), error);
                    return(null);
                }
            }));

            var result = responses.SelectMany(response => response.UnwrapPayloadArray()
                                              .OfType <JsonDataMap>()
                                              .Select(imap => JsonReader.ToDoc <Message>(imap)))
                         .OrderBy(m => m.UTCTimeStamp)
                         .ToArray();

            return(result);
        }
Esempio n. 2
0
        private async Task <IEnumerable <Message> > getOneShard(LogChronicleFilter filter)
        {
            var response = await m_Server.Call(LogServiceAddress,
                                               nameof(ILogChronicle),
                                               0,
                                               (http, ct) => http.Client.PostAndGetJsonMapAsync("filter", filter));

            var result = response.UnwrapPayloadArray()
                         .OfType <JsonDataMap>()
                         .Select(imap => JsonReader.ToDoc <Message>(imap));

            return(result);
        }
Esempio n. 3
0
 public async Task <IEnumerable <Message> > GetAsync(LogChronicleFilter filter)
 => await(filter.NonNull(nameof(filter)).CrossShard ? getCrossShard(filter)
                                                  : getOneShard(filter));