Skip to content

Latest commit

 

History

History
103 lines (75 loc) · 2.73 KB

File metadata and controls

103 lines (75 loc) · 2.73 KB

GreptimeDB .NET Ingester

CI NuGet License .NET

.NET SDK for writing data to GreptimeDB.

Warning This project is under heavy development. APIs may change without notice. Use at your own risk in production environments.

Installation

dotnet add package GreptimeDB.Ingester

Quick Start

using GreptimeDB.Ingester.Client;
using GreptimeDB.Ingester.Table;
using GreptimeDB.Ingester.Types;

// Create client
var client = new GreptimeClient(new GreptimeClientOptions
{
    Endpoint = "http://localhost:4001",
    Database = "public"
});

// Build table
var table = new TableBuilder("cpu_metrics")
    .AddTag("host", ColumnDataType.String)
    .AddField("usage", ColumnDataType.Float64)
    .AddTimestamp("ts", ColumnDataType.TimestampMillisecond)
    .AddRow("server1", 0.85, DateTime.UtcNow)
    .AddRow("server2", 0.72, DateTime.UtcNow)
    .Build();

// Write
var affectedRows = await client.WriteAsync(table);

// Cleanup
await client.DisposeAsync();

Features

  • Unary Write - Simple single-request writes via gRPC
  • Streaming Write - High-throughput streaming via gRPC for multiple tables
  • Bulk Write - Maximum throughput via Apache Arrow Flight
  • Type coercion between .NET and GreptimeDB types
  • Health check
  • DI integration

Streaming Write

For high-throughput scenarios with multiple tables:

await using var writer = client.CreateStreamIngestWriter();

// Write multiple tables in a single stream
await writer.WriteAsync(table1);
await writer.WriteAsync(table2);
await writer.WriteAsync(table3);

var affectedRows = await writer.CompleteAsync();

Bulk Write (Arrow Flight)

For maximum throughput using Apache Arrow Flight protocol:

// Note: Tables must exist before using BulkWriter
await using var writer = client.CreateBulkWriter();

await writer.WriteAsync(table1);
await writer.WriteAsync(table2);

var affectedRows = await writer.CompleteAsync();

Note: Unlike regular gRPC writes, Arrow Flight DoPut does not auto-create tables. Ensure tables exist before using BulkWriter.

DI Integration

services.AddGreptimeClient(options =>
{
    options.Endpoint = "http://localhost:4001";
    options.Database = "public";
});

License

Apache License 2.0