Example #1
0
        public async Task <IAnalyticsResult <T> > AnalyticsQueryAsync <T>(string statement, AnalyticsOptions?options = default)
        {
            options ??= new AnalyticsOptions();
            options.TimeoutValue ??= _context.ClusterOptions.AnalyticsTimeout;

            ThrowIfNotBootstrapped();

            var query = new AnalyticsRequest(statement)
            {
                ClientContextId     = options.ClientContextIdValue,
                NamedParameters     = options.NamedParameters,
                PositionalArguments = options.PositionalParameters,
                Timeout             = options.TimeoutValue.Value
            };

            query.Priority(options.PriorityValue);
            query.ScanConsistency(options.ScanConsistencyValue);

            async Task <IAnalyticsResult <T> > Func()
            {
                var client1  = LazyAnalyticsClient.Value;
                var query1   = query;
                var options1 = options ?? new AnalyticsOptions();

                return(await client1.QueryAsync <T>(query1, options1.Token).ConfigureAwait(false));
            }

            return(await _retryOrchestrator.RetryAsync(Func, query).ConfigureAwait(false));
        }