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_client_context_id() { var request = new AnalyticsRequest(Statement); request.ClientContextId("testing"); var formValues = request.GetFormValues(); var requestId = formValues["client_context_id"].ToString(); Assert.NotEmpty(requestId); var parts = requestId.Split(new[] { "::" }, StringSplitOptions.RemoveEmptyEntries); Assert.Equal(2, parts.Length); Assert.Equal("testing", parts[0]); Assert.True(Guid.TryParse(parts[1], out _)); }