public Task <IAnalyticsResult <T> > AnalyticsQueryAsync <T>(string statement, AnalyticsOptions options = default) { if (options == default) { options = new AnalyticsOptions(); } var query = new AnalyticsRequest(statement); query.ClientContextId(options.ClientContextId); query.Pretty(options.Pretty); query.IncludeMetrics(options.IncludeMetrics); query.NamedParameters = options.NamedParameters; query.PositionalArguments = options.PositionalParameters; if (options.Timeout.HasValue) { query.Timeout(options.Timeout.Value); } query.Priority(options.Priority); query.Deferred(options.Deferred); query.ConfigureLifespan(30); //TODO: use configuration.AnalyticsTimeout if (_analyticsClient == null) { _analyticsClient = new AnalyticsClient(_configuration); } return(_analyticsClient.QueryAsync <T>(query, options.CancellationToken)); }
public async Task <IAnalyticsResult <T> > AnalyticsQueryAsync <T>(string statement, AnalyticsOptions options = default) { await EnsureBootstrapped(); if (options == default) { options = new AnalyticsOptions(); } var query = new AnalyticsRequest(statement); query.ClientContextId(options.ClientContextId); query.Pretty(options.Pretty); query.IncludeMetrics(options.IncludeMetrics); query.NamedParameters = options.NamedParameters; query.PositionalArguments = options.PositionalParameters; if (options.Timeout.HasValue) { query.Timeout(options.Timeout.Value); } query.Priority(options.Priority); query.Deferred(options.Deferred); query.ConfigureLifespan(30); //TODO: use clusterOptions.AnalyticsTimeout return(await _lazyAnalyticsClient.Value.QueryAsync <T>(query, options.CancellationToken)); }
public void Can_set_metrics_parameter() { var request = new AnalyticsRequest(Statement); request.IncludeMetrics(true); var formValues = request.GetFormValues(); Assert.Equal(true, formValues["metrics"]); var json = JsonConvert.DeserializeObject <dynamic>( request.GetFormValuesAsJson() ); Assert.Equal(true, json.metrics.Value); }