Git Product home page Git Product logo

influxdb2.client's Introduction

Influxdb2.Client

Influxdb2读写性能最快的dotnet客户端,读写性能为官方客户端库的180%(本机mock Influxdb服务器,完整的读写流程)

dotnet add package Influxdb2.Client

服务注册

services.AddInfuxdb(o =>
{
    o.Host = new Uri("http://localhost:8086");
    o.Token = "base64 token value";
    o.DefaultOrg = "my-org";
    o.DefaultBucket = "my-bucket";
});

服务获取

MyService(IInfuxdb infuxdb)
{
}

写入数据

var book = new Book();
await infuxdb.WriteAsync(book);

或者

var book = new PointBuilder("Book")
    .SetTag("key", "value")
    .SetField("field", "value")
    .Build();
await infuxdb.WriteAsync(book);

数据属性需要ColumnType标记

class Book
{
    [ColumnType(ColumnType.Tag)]
    public string Serie { get; set; }


    [ColumnType(ColumnType.Field)]
    public string Name { get; set; }


    [ColumnType(ColumnType.Field)]
    public double? Price { get; set; }


    [ColumnType(ColumnType.Field)]
    public bool? SpecialOffer { get; set; }


    [ColumnType(ColumnType.Timestamp)]
    public DateTimeOffset? CreateTime { get; set; } 
}

读取数据

var flux = Flux
    .From(defaultBucket)
    .Range("-3d")
    .Filter(FnBody.R.MeasurementEquals($"{nameof(Book)}"))
    .Pivot()
    .Sort(Columns.Time, desc: true)
    .Limit(10)
    ;

var tables = await infuxdb.QueryAsync(flux);
// 可以映射为任意模型(未必是Book)
var books = tables.Single().ToModels<Book>();

influxdb2.client's People

Contributors

xljiulang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.