예제 #1
0
        protected override Task <IAsyncEnumerator <RavenJObject> > GetDocuments(Etag lastEtag)
        {
            if (IsDocsStreamingSupported)
            {
                ShowProgress("Streaming documents from " + lastEtag);
                return(Commands.StreamDocsAsync(lastEtag));
            }

            int retries = RetriesCount;

            while (true)
            {
                try
                {
                    RavenJArray documents = null;
                    var         url       = "/docs?pageSize=" + SmugglerOptions.BatchSize + "&etag=" + lastEtag;
                    ShowProgress("GET " + url);
                    var request = CreateRequest(url);
                    request.ExecuteRequest(reader => documents = RavenJArray.Load(new JsonTextReader(reader)));

                    return(new CompletedTask <IAsyncEnumerator <RavenJObject> >(new AsyncEnumeratorBridge <RavenJObject>(documents.Values <RavenJObject>().GetEnumerator())));
                }
                catch (Exception e)
                {
                    if (retries-- == 0)
                    {
                        throw;
                    }
                    LastRequestErrored = true;
                    ShowProgress("Error reading from database, remaining attempts {0}, will retry. Error: {1}", retries, e, RetriesCount);
                }
            }
        }
예제 #2
0
        protected async override Task <IAsyncEnumerator <RavenJObject> > GetDocuments(RavenConnectionStringOptions src, Etag lastEtag, int take)
        {
            if (IsDocsStreamingSupported)
            {
                ShowProgress("Streaming documents from {0}, batch size {1}", lastEtag, take);
                return(await Commands.StreamDocsAsync(lastEtag, pageSize : take));
            }

            int retries = RetriesCount;

            while (true)
            {
                try
                {
                    RavenJArray documents = null;
                    var         url       = "/docs?pageSize=" + Math.Min(SmugglerOptions.BatchSize, take) + "&etag=" + lastEtag;
                    ShowProgress("GET " + url);
                    var request = CreateRequest(src, url);
                    request.ExecuteRequest(reader => documents = RavenJArray.Load(new JsonTextReader(reader)));

                    return(new AsyncEnumeratorBridge <RavenJObject>(documents.Values <RavenJObject>().GetEnumerator()));
                }
                catch (Exception e)
                {
                    if (retries-- == 0)
                    {
                        throw;
                    }
                    LastRequestErrored = true;
                    ShowProgress("Error reading from database, remaining attempts {0}, will retry. Error: {1}", retries, e);
                }
            }
        }
예제 #3
0
 protected override Task <IAsyncEnumerator <RavenJObject> > GetDocuments(Etag lastEtag, int limit)
 {
     return(commands.StreamDocsAsync(lastEtag, pageSize: limit));
 }
예제 #4
0
        private async Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(Etag fromEtag, string startsWith, string matches, int start, int pageSize)
        {
            var enumerator = await AsyncDatabaseCommands.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize);

            return(new DocsYieldStream <T>(this, enumerator));
        }
예제 #5
0
        private async Task <IAsyncEnumerator <StreamResult <T> > > StreamAsync <T>(Etag fromEtag, string startsWith, string matches, int start, int pageSize, RavenPagingInformation pagingInformation = null)
        {
            var enumerator = await AsyncDatabaseCommands.StreamDocsAsync(fromEtag, startsWith, matches, start, pageSize, pagingInformation : pagingInformation).ConfigureAwait(false);

            return(new DocsYieldStream <T>(this, enumerator));
        }