该库使成为.NET上的infuxdb的客户很容易!
库背后的基本思想是,它应该能够将查询直接转换为您自己类的对象。很像微型士兵,例如Dapper。
目标是我们希望将来能够支持LINQ语法。
使用以下命令将其通过Nuget安装。
Install-Package Vibrant.InfluxDB.Client
包装可以在这里找到。
或者,您可以简单地将其抓住在GitHub版本之一中。
该库在InfluxDB(1.0+)上公开所有HTTP操作,可用于以两种主要方式读取/写入数据:
这里有一个简单的示例,可以在此处提供。
首先定义一个代表您要存储的InfluxDB中一行的类。
public class ComputerInfo
{
[ InfluxTimestamp ]
public DateTime Timestamp { get ; set ; }
[ InfluxTag ( "host" ) ]
public string Host { get ; set ; }
[ InfluxTag ( "region" ) ]
public string Region { get ; set ; }
[ InfluxField ( "cpu" ) ]
public double CPU { get ; set ; }
[ InfluxField ( "ram" ) ]
public long RAM { get ; set ; }
}在您的POCO课上,您必须指定这些内容:
定义了课程后,您就可以使用流入器,这是API的主要入口处:
这是写入数据库的方法:
private ComputerInfo [ ] CreateTypedRowsStartingAt ( DateTime start , int rows )
{
var rng = new Random ( ) ;
var regions = new [ ] { "west-eu" , "north-eu" , "west-us" , "east-us" , "asia" } ;
var hosts = new [ ] { "some-host" , "some-other-host" } ;
var timestamp = start ;
var infos = new ComputerInfo [ rows ] ;
for ( int i = 0 ; i < rows ; i ++ )
{
long ram = rng . Next ( int . MaxValue ) ;
double cpu = rng . NextDouble ( ) ;
string region = regions [ rng . Next ( regions . Length ) ] ;
string host = hosts [ rng . Next ( hosts . Length ) ] ;
var info = new ComputerInfo { Timestamp = timestamp , CPU = cpu , RAM = ram , Host = host , Region = region } ;
infos [ i ] = info ;
timestamp = timestamp . AddSeconds ( 1 ) ;
}
return infos ;
}
public async Task Should_Write_Typed_Rows_To_Database ( )
{
var client = new InfluxClient ( new Uri ( "http://localhost:8086" ) ) ;
var infos = CreateTypedRowsStartingAt ( new DateTime ( 2010 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) , 500 ) ;
await client . WriteAsync ( "mydb" , "myMeasurementName" , infos ) ;
}这是从数据库中查询的方法:
public async Task Should_Query_Typed_Data ( )
{
var resultSet = await client . ReadAsync < ComputerInfo > ( "mydb" , "SELECT * FROM myMeasurementName" ) ;
// resultSet will contain 1 result in the Results collection (or multiple if you execute multiple queries at once)
var result = resultSet . Results [ 0 ] ;
// result will contain 1 series in the Series collection (or potentially multiple if you specify a GROUP BY clause)
var series = result . Series [ 0 ] ;
// series.Rows will be the list of ComputerInfo that you queried for
foreach ( var row in series . Rows )
{
Console . WriteLine ( "Timestamp: " + row . Timestamp ) ;
Console . WriteLine ( "CPU: " + row . CPU ) ;
Console . WriteLine ( "RAM: " + row . RAM ) ;
// ...
}
}POCO类并不适合每个用例。一旦您实现了系统,这将变得显而易见,并且您不知道编译时的字段/标签将是什么。在这种情况下,您必须使用动态类。
为了使此工作起作用,您必须使用指定标签和字段读取方法的接口iinfluxrow。该库已经包含了使用字典的一个实现该界面的实现,并为DLR提供了基本支持。该类称为Dynamicinfluxrow。
这是使用动态类写作的方法。
private DynamicInfluxRow [ ] CreateDynamicRowsStartingAt ( DateTime start , int rows )
{
var rng = new Random ( ) ;
var regions = new [ ] { "west-eu" , "north-eu" , "west-us" , "east-us" , "asia" } ;
var hosts = new [ ] { "some-host" , "some-other-host" } ;
var timestamp = start ;
var infos = new DynamicInfluxRow [ rows ] ;
for ( int i = 0 ; i < rows ; i ++ )
{
long ram = rng . Next ( int . MaxValue ) ;
double cpu = rng . NextDouble ( ) ;
string region = regions [ rng . Next ( regions . Length ) ] ;
string host = hosts [ rng . Next ( hosts . Length ) ] ;
var info = new DynamicInfluxRow ( ) ;
info . Fields . Add ( "cpu" , cpu ) ;
info . Fields . Add ( "ram" , ram ) ;
info . Tags . Add ( "host" , host ) ;
info . Tags . Add ( "region" , region ) ;
info . Timestamp = timestamp ;
infos [ i ] = info ;
timestamp = timestamp . AddSeconds ( 1 ) ;
}
return infos ;
}
public async Task Should_Write_Dynamic_Rows_To_Database ( )
{
var client = new InfluxClient ( new Uri ( "http://localhost:8086" ) ) ;
var infos = CreateDynamicRowsStartingAt ( new DateTime ( 2010 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) , 500 ) ;
await client . WriteAsync ( "mydb" , "myMeasurementName" , infos ) ;
}请注意,如果您使用动态类,用户定义的枚举和数据记录作为字段/标签不支持,因为无法区分字符串和枚举/dateTime。
另请注意,如果要使用此接口使用自定义时间戳类型或DateTimeOffset,则可以使用通用的Iinfluxrow接口或DynamicInfluxrow类。
这是从数据库中查询的方法:
public async Task Should_Query_Dynamic_Data ( )
{
var resultSet = await client . ReadAsync < DynamicInfluxRow > ( "mydb" , "SELECT * FROM myMeasurementName" ) ;
// resultSet will contain 1 result in the Results collection (or multiple if you execute multiple queries at once)
var result = resultSet . Results [ 0 ] ;
// result will contain 1 series in the Series collection (or potentially multiple if you specify a GROUP BY clause)
var series = result . Series [ 0 ] ;
// series.Rows will be the list of DynamicInfluxRow that you queried for (which can be cast to dynamic)
foreach ( dynamic row in series . Rows )
{
Console . WriteLine ( "Timestamp: " + row . time ) ; // Can also access row.Timestamp
Console . WriteLine ( "CPU: " + row . cpu ) ;
Console . WriteLine ( "RAM: " + row . ram ) ;
// ...
}
} 通常,您可能不会选择所插入的确切结构。也许您正在对正在检索的数据进行一些聚合或计算,以更改返回列的名称。
在这种情况下,您可以简单地定义一个新类并使用infuxcomputateDattribute。与属性中指定的名称匹配的任何列(标签或字段,是否汇总)都将使用此属性进入属性。
[ InfluxComputedAttribute ]具有此属性的类不应用于插入,因为客户无法知道其是字段还是标签。
如果您使用的是Iinfluxrow接口(例如DynamicInfluxrow),则“字段”集合填充了所有与特定测量的已知标签不匹配的所有列。
有时,您可能会从数据库中检索大量数据,实际上是如此之多,以至于任何时候都将其全部保存在记忆中是不可行的。在这种情况下,您需要InfluxDB提供的分块功能。您可以通过在InfuxqueryOptions类中启用分块来利用此功能。启用后,客户将在检索数据时向涌入的群体提供块状选项。
但是,默认的readasync操作将只需在将控件返回给用户之前读取所有块即可。为了支持您想通过块读取数据的方案,可以使用方法ReadChunkedAsync。这将返回不同类型的结果集,使您可以在所有块上进行异步迭代(同时仍保持最初进行的查询的结构)。这是从单位测试中获取的示例:
[ Fact ]
public async Task Should_Write_And_Query_Deferred_Grouped_Data_With_Multi_Query ( )
{
var start = new DateTime ( 2011 , 1 , 1 , 1 , 1 , 1 , DateTimeKind . Utc ) ;
var infos = InfluxClientFixture . CreateTypedRowsStartingAt ( start , 5000 , false ) ;
await client . WriteAsync ( InfluxClientFixture . DatabaseName , "groupedComputerInfo4" , infos ) ;
await client . WriteAsync ( InfluxClientFixture . DatabaseName , "groupedComputerInfo5" , infos ) ;
var chunkedResultSet = await client . ReadChunkedAsync < ComputerInfo > (
InfluxClientFixture . DatabaseName ,
$ "SELECT * FROM groupedComputerInfo4 GROUP BY region;SELECT * FROM groupedComputerInfo5 GROUP BY region" ,
new InfluxQueryOptions { ChunkSize = 200 } ) ;
InfluxChunkedResult < ComputerInfo > currentResult ;
InfluxChunkedSeries < ComputerInfo > currentSerie ;
InfluxChunk < ComputerInfo > currentChunk ;
int resultCount = 0 ;
int serieCount = 0 ;
int rowCount = 0 ;
using ( chunkedResultSet )
{
while ( ( currentResult = await chunkedResultSet . GetNextResultAsync ( ) ) != null )
{
while ( ( currentSerie = await currentResult . GetNextSeriesAsync ( ) ) != null )
{
while ( ( currentChunk = await currentSerie . GetNextChunkAsync ( ) ) != null )
{
rowCount += currentChunk . Rows . Count ;
}
serieCount ++ ;
}
resultCount ++ ;
}
}
Assert . Equal ( 1 * 2 , resultCount ) ;
Assert . Equal ( InfluxClientFixture . Regions . Length * 2 , serieCount ) ;
Assert . Equal ( 5000 * 2 , rowCount ) ;
}在C#的即将到来的版本中,将有能力迭代异步枚举,一旦此功能达到了,我也将支持这一点。请参阅下面的视频:
https://channel9.msdn.com/blogs/seth-juarez/a-preview-erview-of-c--c--c-----------mads-torgersen#time=16m30s
指定时区子句时,InfluxDB将返回时间戳,其偏移量。您可以使用DateTimeOffset或可将其作为时间戳类型保存在返回的时间戳中。如果使用日期时间或可将其作为时间戳类型,则时间戳将始终转换为UTC。
另外,您可以实现自己的Itimestampparser来支持自定义类型,例如Nodatime。实施后,您可以在流入器上注册。只需实现以下接口:
/// <summary>
/// ITimestampParser is responsible for parsing the 'time' column
/// of data returned, allowing use of custom DateTime types.
/// </summary>
/// <typeparam name="TTimestamp"></typeparam>
public interface ITimestampParser < TTimestamp >
{
/// <summary>
/// Parses a epoch time (UTC) or ISO8601-timestamp (potentially with offset) to a date and time.
/// This is used when reading data from influxdb.
/// </summary>
/// <param name="precision">TimestampPrecision provided by the current InfluxQueryOptions.</param>
/// <param name="epochTimeLongOrIsoTimestampString">The raw value returned by the query.</param>
/// <returns>The parsed timestamp.</returns>
TTimestamp ToTimestamp ( TimestampPrecision ? precision , object epochTimeLongOrIsoTimestampString ) ;
/// <summary>
/// Converts the timestamp to epoch time (UTC). This is used when writing data to influxdb.
/// </summary>
/// <param name="precision">TimestampPrecision provided by the current InfluxWriteOptions.</param>
/// <param name="timestamp">The timestamp to convert.</param>
/// <returns>The UTC epoch time.</returns>
long ToEpoch ( TimestampPrecision precision , TTimestamp timestamp ) ;
} 通常,您可能需要通过执行单个呼叫来写入具有不同测量名称的多个测量值。
这可以通过在POCO类上实现以下接口来实现:
/// <summary>
/// Interface that can be used to specify a per-row measurement name.
/// </summary>
public interface IHaveMeasurementName
{
/// <summary>
/// Gets or sets the measurement name.
/// </summary>
string MeasurementName { get ; set ; }
}
或通过将[涌入]属性放在您的POCO类的班级或属性定义上。
在课堂上使用它时,您必须指定一个名称,例如:
[ InfluxMeasurement ( "MyTableName" ) ]
public class ClassWithMeasurementName
{
[ InfluxTimestamp ]
internal DateTime Timestamp { get ; set ; }
[ InfluxField ( "cpu" ) ]
internal double ? CPU { get ; set ; }
}在属性上使用它时,请勿指定名称。它将使用属性值(必须是字符串):
public class ClassWithMeasurementName
{
[ InfluxTimestamp ]
internal DateTime Timestamp { get ; set ; }
[ InfluxField ( "cpu" ) ]
internal double ? CPU { get ; set ; }
[ InfluxMeasurement ]
public string TableName { get ; set ; }
}当使用其中一种方法时,您可以使用以下过载writeasync方法,该方法不会以MeasurementName作为参数:
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows )
public Task WriteAsync < TInfluxRow > ( string db , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options )
如果您想使用动态类执行此操作,则可以简单地使用nationdynamicinfluxrow(实现IhaveMeasurementName接口)。
如果使用多种方法,则使用以下优先级来确定要编写记录的测量值:
如果您使用IhaveMeasurementName或具有涌入量的属性,则测量名称将在阅读操作期间写入该属性。
流入器还支持参数结合,以支持预防SQL注入。
要使用此功能,只需使用采用参数“对象参数”的方法。这可以是一个匿名对象,字典或任何支持JSON序列化的对象。
当对象或字典中的参数化值时,请勿将名称前缀为$,例如名称在实际查询中。
这是一个外观的示例:
var resultSet = await client . ReadAsync < ComputerInfo > (
db ,
"SELECT * FROM myMeasurementName WHERE time >= $myParam" ,
new { myParam = new DateTime ( 2010 , 1 , 1 , 1 , 1 , 3 , DateTimeKind . Utc ) } ) ;您通常通过此客户端库使用的任何类型都可以用作参数。
与InfluxDB相互作用的主要接口在下面可以看到。
public interface IInfluxClient
{
/// <summary>
/// Gets the default query optionns.
/// </summary>
InfluxQueryOptions DefaultQueryOptions { get ; }
/// <summary>
/// Gets the default write options.
/// </summary>
InfluxWriteOptions DefaultWriteOptions { get ; }
/// <summary>
/// Gets or sets the timeout for all requests made.
/// </summary>
TimeSpan Timeout { get ; set ; }
/// <summary>
/// Gets the timestamp parser registry.
/// </summary>
ITimestampParserRegistry TimestampParserRegistry { get ; }
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet > ExecuteOperationAsync ( string commandOrQuery , string db , object parameters ) ;
/// <summary>
/// Executes an arbitrary command that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( string commandOrQuery , string db , object parameters ) where TInfluxRow : new ( ) ;
/// <summary>
/// Executes a ping and waits for the leader to respond.
/// </summary>
/// <param name="secondsToWaitForLeader"></param>
/// <returns></returns>
Task < InfluxPingResult > PingAsync ( int ? secondsToWaitForLeader ) ;
/// <summary>
/// Executes the query and returns the result with the specified query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="options"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( string db , string query , object parameters , InfluxQueryOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="options"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( string db , string query , object parameters , InfluxQueryOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Writes the rows with the specified write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="rows"></param>
/// <param name="options"></param>
/// <returns></returns>
Task WriteAsync < TInfluxRow > ( string db , string measurementName , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options ) where TInfluxRow : new ( ) ;
/// <summary>
/// Deletes data in accordance with the specified query
/// </summary>
/// <param name="db"></param>
/// <param name="deleteQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
Task < InfluxResult > DeleteAsync ( string db , string deleteQuery , object parameters ) ;
}除此接口外,还提供了许多扩展方法:
public static class InfluxClientExtensions
{
#region Raw Operations
/// <summary>
/// Executes an arbitrary command that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery , string db ) ;
/// <summary>
/// Executes an arbitrary command or query that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery ) ;
/// <summary>
/// Executes an arbitrary command or query that returns a table as a result.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ExecuteOperationAsync < TInfluxRow > ( this IInfluxClient client , string commandOrQuery , object parameters ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery , string db ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery ) ;
/// <summary>
/// Executes an arbitrary command that does not return a table.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="commandOrQuery"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet > ExecuteOperationAsync ( this IInfluxClient client , string commandOrQuery , object parameters ) ;
#endregion
#region System Monitoring
/// <summary>
/// Shows InfluxDB stats.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowStatsAsync < TInfluxRow > ( this IInfluxClient client ) ;
/// <summary>
/// Shows InfluxDB diagnostics.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowDiagnosticsAsync < TInfluxRow > ( this IInfluxClient client ) ;
/// <summary>
/// Shows Shards.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < ShardRow > > ShowShards ( this IInfluxClient client ) ;
#endregion
#region Authentication and Authorization
/// <summary>
/// CREATE a new admin user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static Task < InfluxResultSet > CreateAdminUserAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// CREATE a new non-admin user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateUserAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// GRANT administrative privileges to an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > GrantAdminPrivilegesAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// GRANT READ, WRITE or ALL database privileges to an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="privilege"></param>
/// <param name="db"></param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > GrantPrivilegeAsync ( this IInfluxClient client , string db , DatabasePriviledge privilege , string username ) ;
/// <summary>
/// REVOKE administrative privileges from an admin user
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > RevokeAdminPrivilegesAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// REVOKE READ, WRITE, or ALL database privileges from an existing user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="privilege"></param>
/// <param name="db"></param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > RevokePrivilegeAsync ( this IInfluxClient client , string db , DatabasePriviledge privilege , string username ) ;
/// <summary>
/// SET a user’s password.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <param name="password"></param>
/// <returns></returns>
public static async Task < InfluxResult > SetPasswordAsync ( this IInfluxClient client , string username , string password ) ;
/// <summary>
/// DROP a user.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropUserAsync ( this IInfluxClient client , string username ) ;
/// <summary>
/// SHOW all existing users and their admin status.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < UserRow > > ShowUsersAsync ( this IInfluxClient client ) ;
/// <summary>
/// SHOW a user’s database privileges.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="username"></param>
/// <returns></returns>
public static async Task < InfluxResult < GrantsRow > > ShowGrantsAsync ( this IInfluxClient client , string username ) ;
#endregion
#region Database Management
/// <summary>
/// Create a database with CREATE DATABASE.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateDatabaseAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// Delete a database with DROP DATABASE
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropDatabaseAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// Delete series with DROP SERIES
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropSeries ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// Delete series with DROP SERIES
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropSeries ( this IInfluxClient client , string db , string measurementName , string where ) ;
/// <summary>
/// Delete measurements with DROP MEASUREMENT
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="measurementName"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropMeasurementAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// Create retention policies with CREATE RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , bool isDefault ) ;
/// <summary>
/// Create retention policies with CREATE RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="shardGroupDuration"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , string shardGroupDuration , bool isDefault ) ;
/// <summary>
/// Modify retention policies with ALTER RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > AlterRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , bool isDefault ) ;
/// <summary>
/// Modify retention policies with ALTER RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <param name="duration"></param>
/// <param name="replicationLevel"></param>
/// <param name="shardGroupDuration"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public static async Task < InfluxResult > AlterRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName , string duration , int replicationLevel , string shardGroupDuration , bool isDefault ) ;
/// <summary>
/// Delete retention policies with DROP RETENTION POLICY
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="policyName"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropRetentionPolicyAsync ( this IInfluxClient client , string db , string policyName ) ;
#endregion
#region Continous Queries
/// <summary>
/// To see the continuous queries you have defined, query SHOW CONTINUOUS QUERIES and InfluxDB will return the name and query for each continuous query in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < ContinuousQueryRow > > ShowContinuousQueries ( this IInfluxClient client , string db ) ;
/// <summary>
/// Creates a continuous query.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="name"></param>
/// <param name="db"></param>
/// <param name="continuousQuery"></param>
/// <returns></returns>
public static async Task < InfluxResult > CreateContinuousQuery ( this IInfluxClient client , string db , string name , string continuousQuery ) ;
/// <summary>
/// Drops a continuous query.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="name"></param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult > DropContinuousQuery ( this IInfluxClient client , string db , string name ) ;
#endregion
#region Schema Exploration
/// <summary>
/// Get a list of all the databases in your system.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static async Task < InfluxResult < DatabaseRow > > ShowDatabasesAsync ( this IInfluxClient client ) ;
/// <summary>
/// The SHOW RETENTION POLICIES query lists the existing retention policies on a given database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < RetentionPolicyRow > > ShowRetentionPoliciesAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// The SHOW SERIES query returns the distinct series in your database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < ShowSeriesRow > > ShowSeriesAsync ( this IInfluxClient client , string db , string measurementName , string where ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsAsync ( this IInfluxClient client , string db , string where ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementRegex"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsWithMeasurementAsync ( this IInfluxClient client , string db , string measurementRegex ) ;
/// <summary>
/// The SHOW MEASUREMENTS query returns the measurements in your database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementRegex"></param>
/// <param name="where"></param>
/// <returns></returns>
public static async Task < InfluxResult < MeasurementRow > > ShowMeasurementsWithMeasurementAsync ( this IInfluxClient client , string db , string measurementRegex , string where ) ;
/// <summary>
/// SHOW TAG KEYS returns the tag keys associated with each measurement.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < TagKeyRow > > ShowTagKeysAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// SHOW TAG KEYS returns the tag keys associated with each measurement.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < TagKeyRow > > ShowTagKeysAsync ( this IInfluxClient client , string db , string measurementName ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowTagValuesAsAsync < TInfluxRow , TValue > ( this IInfluxClient client , string db , string tagKey ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <typeparam name="TValue"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < TInfluxRow > > ShowTagValuesAsAsync < TInfluxRow , TValue > ( this IInfluxClient client , string db , string tagKey , string measurementName ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <returns></returns>
public static Task < InfluxResult < TagValueRow > > ShowTagValuesAsync ( this IInfluxClient client , string db , string tagKey ) ;
/// <summary>
/// The SHOW TAG VALUES query returns the set of tag values for a specific tag key across all measurements in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="tagKey"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static Task < InfluxResult < TagValueRow > > ShowTagValuesAsync ( this IInfluxClient client , string db , string tagKey , string measurementName ) ;
/// <summary>
/// The SHOW FIELD KEYS query returns the field keys across each measurement in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <returns></returns>
public static async Task < InfluxResult < FieldKeyRow > > ShowFieldKeysAsync ( this IInfluxClient client , string db ) ;
/// <summary>
/// The SHOW FIELD KEYS query returns the field keys across each measurement in the database.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <returns></returns>
public static async Task < InfluxResult < FieldKeyRow > > ShowFieldKeysAsync ( this IInfluxClient client , string db , string measurementName ) ;
#endregion
#region Ping
/// <summary>
/// Executes a ping.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <returns></returns>
public static Task < InfluxPingResult > PingAsync ( this IInfluxClient client ) ;
#endregion
#region Data Management
/// <summary>
/// Writes the rows with default write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , string measurementName , IEnumerable < TInfluxRow > rows ) ;
/// <summary>
/// Writes the rows with default write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="rows"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , IEnumerable < TInfluxRow > rows ) ;
/// <summary>
/// Writes the rows with the specified write options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="rows"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task WriteAsync < TInfluxRow > ( this IInfluxClient client , string db , IEnumerable < TInfluxRow > rows , InfluxWriteOptions options ) ;
/// <summary>
/// Executes the query and returns the result with the default query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query ) ;
/// <summary>
/// Executes the query and returns the result with the default query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , object parameters ) ;
/// <summary>
/// Executes the query and returns the result with the specified query options.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="query"></param>
/// <param name="db"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task < InfluxResultSet < TInfluxRow > > ReadAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , InfluxQueryOptions options ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="parameters"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , object parameters ) ;
/// <summary>
/// Executes the query and returns a deferred result that can be iterated over as they
/// are returned by the database.
///
/// It does not make sense to use this method unless you are returning a big payload and
/// have enabled chunking through InfluxQueryOptions.
/// </summary>
/// <typeparam name="TInfluxRow"></typeparam>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="query"></param>
/// <param name="options"></param>
/// <returns></returns>
public static Task < InfluxChunkedResultSet < TInfluxRow > > ReadChunkedAsync < TInfluxRow > ( this IInfluxClient client , string db , string query , InfluxQueryOptions options ) ;
/// <summary>
/// Deletes data in accordance with the specified query
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="deleteQuery"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteAsync ( this IInfluxClient client , string db , string deleteQuery ) ;
/// <summary>
/// Deletes all data older than the specified timestamp.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="to"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteOlderThanAsync ( this IInfluxClient client , string db , string measurementName , DateTime to ) ;
/// <summary>
/// Deletes all data in the specified range.
/// </summary>
/// <param name="client">The IInfluxClient that performs operation.</param>
/// <param name="db"></param>
/// <param name="measurementName"></param>
/// <param name="from"></param>
/// <param name="to"></param>
/// <returns></returns>
public static Task < InfluxResult > DeleteRangeAsync ( this IInfluxClient client , string db , string measurementName , DateTime from , DateTime to ) ;
#endregion
}为了确切指示每个参数的内容,请参阅InfluxDB提供的文档页面: