Class FluxClient
Inheritance
Namespace: InfluxDB.Client.Flux
Assembly: InfluxDB.Client.Flux.dll
Syntax
public class FluxClient : AbstractQueryClient, IFluxClient, IDisposable
Constructors
FluxClient(FluxConnectionOptions)
Create a instance of the Flux client.
Declaration
public FluxClient(FluxConnectionOptions options)
Parameters
Type | Name | Description |
---|---|---|
FluxConnectionOptions | options | the connection configuration |
FluxClient(String)
Create a instance of the Flux client. The url could be a connection string with various configurations.
e.g.: "http://localhost:8086?timeout=5000&logLevel=BASIC The following options are supported:
Declaration
public FluxClient(string connectionString)
Parameters
Type | Name | Description |
---|---|---|
System.String | connectionString | the connectionString to connect to InfluxDB |
Methods
AfterIntercept<T>(Int32, Func<IEnumerable<HeaderParameter>>, T)
Declaration
protected override T AfterIntercept<T>(int statusCode, Func<IEnumerable<HeaderParameter>> headers, T body)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | statusCode | |
Func<IEnumerable<HeaderParameter>> | headers | |
T | body |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T |
BeforeIntercept(RestRequest)
Declaration
protected override void BeforeIntercept(RestRequest request)
Parameters
Type | Name | Description |
---|---|---|
RestRequest | request |
Dispose()
Declaration
public void Dispose()
GetLogLevel()
Set the LogLevel that is used for logging requests and responses.
Declaration
public LogLevel GetLogLevel()
Returns
Type | Description |
---|---|
LogLevel | Log Level |
PingAsync(CancellationToken)
Check the status of InfluxDB Server.
Declaration
public async Task<bool> PingAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
Task<System.Boolean> | true if server is healthy otherwise return false |
QueryAsync(String, Action<FluxRecord>, Action<Exception>, Action, CancellationToken)
Executes the Flux query against the InfluxDB and asynchronously stream FluxRecord to
Declaration
public Task QueryAsync(string query, Action<FluxRecord> onNext, Action<Exception> onError = null, Action onComplete = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute |
Action<FluxRecord> | onNext | the callback to consume the FluxRecord result |
Action<Exception> | onError | the callback to consume any error notification |
Action | onComplete | the callback to consume a notification about successfully end of stream |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task | async task |
QueryAsync(String, CancellationToken)
Executes the Flux query against the InfluxDB and asynchronously map whole response to
Declaration
public async Task<List<FluxTable>> QueryAsync(string query, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task<List<FluxTable>> |
QueryAsync<T>(String, Action<T>, Action<Exception>, Action, CancellationToken)
Executes the Flux query against the InfluxDB and asynchronously stream result as POCO.
Declaration
public Task QueryAsync<T>(string query, Action<T> onNext, Action<Exception> onError = null, Action onComplete = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute |
Action<T> | onNext | the callback to consume the FluxRecord result |
Action<Exception> | onError | the callback to consume any error notification |
Action | onComplete | the callback to consume a notification about successfully end of stream |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task | async task |
Type Parameters
Name | Description |
---|---|
T | the type of measurement |
QueryAsync<T>(String, CancellationToken)
Executes the Flux query against the InfluxDB and asynchronously map whole response to list of object with given type.
NOTE: This method is not intended for large query results.
Use
Declaration
public async Task<List<T>> QueryAsync<T>(string query, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task<List<T>> |
Type Parameters
Name | Description |
---|---|
T | the type of measurement |
QueryRawAsync(String, Action<String>, String, Action<Exception>, Action, CancellationToken)
Executes the Flux query against the InfluxDB and asynchronously stream response (line by line) to
Declaration
public Task QueryRawAsync(string query, Action<string> onResponse, string dialect = null, Action<Exception> onError = null, Action onComplete = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute |
Action<System.String> | onResponse | the callback to consume the response line by line |
System.String | dialect | Dialect is an object defining the options to use when encoding the response. See dialect SPEC. |
Action<Exception> | onError | the callback to consume any error notification |
Action | onComplete | the callback to consume a notification about successfully end of stream |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task | async task |
QueryRawAsync(String, String, CancellationToken)
Executes the Flux query against the InfluxDB and synchronously map whole response to
NOTE: This method is not intended for large responses, that do not fit into memory.
Use
Declaration
public async Task<string> QueryRawAsync(string query, string dialect = null, CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | query | the flux query to execute> |
System.String | dialect | Dialect is an object defining the options to use when encoding the response. See dialect SPEC. |
CancellationToken | cancellationToken | Token that enables callers to cancel the request. |
Returns
Type | Description |
---|---|
Task<System.String> | the raw response that matched the query |
SetLogLevel(LogLevel)
Set the log level for the request and response information.
Declaration
public void SetLogLevel(LogLevel logLevel)
Parameters
Type | Name | Description |
---|---|---|
LogLevel | logLevel | the log level to set |
VersionAsync(CancellationToken)
Return the version of the connected InfluxDB Server.
Declaration
public async Task<string> VersionAsync(CancellationToken cancellationToken = null)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | Cancellation token |
Returns
Type | Description |
---|---|
Task<System.String> | the version String, otherwise unknown |
Exceptions
Type | Condition |
---|---|
InfluxException | throws when request did not succesfully ends |