コード例 #1
0
        public async Task BuildDeferredAsync(string bucketName, BuildDeferredQueryIndexOptions options)
        {
            Logger.LogInformation($"Attempting to build deferred query indexes on bucket {bucketName}");

            try
            {
                var indexes = await this.GetAllAsync(bucketName,
                                                     queryOptions => queryOptions.WithCancellationToken(options.CancellationToken)
                                                     );

                var tasks = new List <Task>();
                foreach (var index in indexes.Where(i => i.State == "pending" || i.State == "deferred"))
                {
                    var statement = $"BUILD INDEX ON {bucketName}({index.Name}) USING GSI;";
                    tasks.Add(_queryClient.QueryAsync <dynamic>(statement,
                                                                queryOptions => queryOptions.WithCancellationToken(options.CancellationToken)
                                                                ));
                }

                await Task.WhenAll(tasks);
            }
            catch (Exception exception)
            {
                Logger.LogError(exception, $"Error trying to build deferred query indexes on {bucketName}");
                throw;
            }
        }
コード例 #2
0
        public static Task BuildDeferredAsync(this IQueryIndexes queryIndexes, string bucketName, Action <BuildDeferredQueryIndexOptions> configureOptions)
        {
            var options = new BuildDeferredQueryIndexOptions();

            configureOptions(options);

            return(queryIndexes.BuildDeferredAsync(bucketName, options));
        }