Skip to content

fix: move headings out from template #1848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions docs/user-guide/ingest-data/for-iot/grpc-sdks/go.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ import DocTemplate from './template.md'
<DocTemplate>

<div id="ingester-lib-introduction">

## Introduction
The Go ingester SDK provided by GreptimeDB is a lightweight,
concurrent-safe library that is easy to use with the metric struct.

</div>

<div id="quick-start-demos">

## Quick start demos
To quickly get started, you can explore the [quick start demos](https://github.com/GreptimeTeam/greptimedb-ingester-go/tree/main/examples) to understand how to use the GreptimeDB Go ingester SDK.

</div>

<div id="ingester-lib-installation">

## Installation
Use the following command to install the GreptimeDB client library for Go:

```shell
Expand All @@ -40,11 +38,10 @@ import (
"github.com/GreptimeTeam/greptimedb-ingester-go/table/types"
)
```

</div>

<div id="ingester-lib-connect">

## Connect to database
```go
cfg := greptime.NewConfig("127.0.0.1").
// change the database name to your database name
Expand All @@ -62,7 +59,7 @@ cli, _ := greptime.NewClient(cfg)
</div>

<div id="set-table-options">

## Set table options
You can set table options using the `ingesterContext` context.
For example, to set the `ttl` option, use the following code:

Expand All @@ -83,11 +80,11 @@ if err != nil {
return err
}
```

</div>

<div id="low-level-object">

## Low-level API
### Create row objects
```go
// Construct the table schema for CPU metrics
cpuMetric, err := table.New("cpu_metric")
Expand All @@ -112,11 +109,10 @@ if err != nil {
}

```

</div>

<div id="create-rows">

### Create multiple rows
```go
cpuMetric, err := table.New("cpu_metric")
if err != nil {
Expand All @@ -143,42 +139,38 @@ if err != nil {
// Handle error appropriately
}
```

</div>

<div id="insert-rows">

### Insert data
```go
resp, err := cli.Write(ctx, cpuMetric, memMetric)
if err != nil {
// Handle error appropriately
}
log.Printf("affected rows: %d\n", resp.GetAffectedRows().GetValue())
```

</div>

<div id="streaming-insert">

### Streaming insert
```go
err := cli.StreamWrite(ctx, cpuMetric, memMetric)
if err != nil {
// Handle error appropriately
}
```

Close the stream writing after all data has been written.
In general, you do not need to close the stream writing when continuously writing data.

```go
affected, err := cli.CloseStream(ctx)
```

</div>


<div id="high-level-style-object">

## High-level API
### Create row objects
```go
type CpuMetric struct {
Host string `greptime:"tag;column:host;type:string"`
Expand Down Expand Up @@ -225,31 +217,28 @@ memMetrics := []MemMetric{
</div>

<div id="high-level-style-insert-data">

### Insert data
```go
resp, err := cli.WriteObject(ctx, cpuMetrics)
log.Printf("affected rows: %d\n", resp.GetAffectedRows().GetValue())
```

</div>

<div id="high-level-style-streaming-insert">

### Streaming insert
```go
err := cli.StreamWriteObject(ctx, cpuMetrics)
```

Close the stream writing after all data has been written.
In general, you do not need to close the stream writing when continuously writing data.

```go
affected, err := cli.CloseStream(ctx)
```

</div>

<div id="ingester-json-type">

## Insert data in JSON type
In the [low-level API](#low-level-api),
you can specify the column type as `types.JSON` using the `AddFieldColumn` method to add a JSON column.
Then, use a `struct` or `map` to insert JSON data.
Expand Down Expand Up @@ -300,13 +289,19 @@ sensor := SensorReadings{
```

For the executable code for inserting JSON data, please refer to the [example](https://github.com/GreptimeTeam/greptimedb-ingester-go/tree/main/examples/jsondata) in the SDK repository.
</div>

<div id="ingester-lib-debug-logs">
## Debug logs
</div>

<div id="ingester-lib-reference">

## Ingester library reference
- [API Documentation](https://pkg.go.dev/github.com/GreptimeTeam/greptimedb-ingester-go)
</div>

<div id="faq">
## FAQ
</div>

</DocTemplate>
45 changes: 18 additions & 27 deletions docs/user-guide/ingest-data/for-iot/grpc-sdks/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import DocTemplate from './template.md'
<DocTemplate>

<div id="ingester-lib-introduction">

## Introduction
The Java ingester SDK provided by GreptimeDB is a lightweight library with the following features:

- SPI-based extensible network transport layer, which provides the default implementation using the gRPC framework.
Expand All @@ -21,13 +21,12 @@ The Java ingester SDK provided by GreptimeDB is a lightweight library with the f
</div>

<div id="quick-start-demos">

## Quick start demos
To quickly get started, you can explore the [quick start demos](https://github.com/GreptimeTeam/greptimedb-ingester-java/tree/main/ingester-example/src/main/java/io/greptime) to understand how to use the GreptimeDB Java ingester SDK.

</div>

<div id="ingester-lib-installation">

## Installation
1. Install the Java Development Kit(JDK)

Make sure that your system has JDK 8 or later installed. For more information on how to
Expand All @@ -53,7 +52,7 @@ After configuring your dependencies, make sure they are available to your projec
</div>

<div id="ingester-lib-connect">

## Connect to database
The following code demonstrates how to connect to GreptimeDB with the simplest configuration.
For customizing the connection options, please refer to [API Documentation](#ingester-library-reference).
Please pay attention to the accompanying comments for each option, as they provide detailed explanations of their respective roles.
Expand Down Expand Up @@ -84,7 +83,7 @@ For customizing the connection options, please refer to [API Documentation](#ing
</div>

<div id="set-table-options">

## Set table options
You can set table options using the `Context`.
For example, to set the `ttl` option, use the following code:

Expand All @@ -102,7 +101,8 @@ CompletableFuture<Result<WriteOk, Err>> future = greptimeDB.write(Arrays.asList(
</div>

<div id="low-level-object">

## Low-level API
### Create row objects
```java
// Construct the table schema for `cpu_metric`.
// The schema is immutable and can be safely reused across multiple operations.
Expand Down Expand Up @@ -140,9 +140,8 @@ cpuMetric.complete();

</div>


<div id="create-rows">

### Create multiple rows
```java
// Define the schema for tables.
// The schema is immutable and can be safely reused across multiple operations.
Expand Down Expand Up @@ -195,9 +194,8 @@ memMetric.complete();

</div>


<div id="insert-rows">

### Insert data
```java
// Saves data

Expand All @@ -220,10 +218,8 @@ if (result.isOk()) {

</div>


<div id="streaming-insert">


### Streaming insert
```java
// Set the compression algorithm to Zstd.
Context ctx = Context.newDefault().withCompression(Compression.Zstd);
Expand Down Expand Up @@ -256,7 +252,8 @@ LOG.info("Write result: {}", result);
</div>

<div id="high-level-style-object">

## High-level API
### Create row objects
GreptimeDB Java Ingester SDK allows us to use basic POJO objects for writing. This approach requires the use of Greptime's own annotations, but they are easy to use.

```java
Expand Down Expand Up @@ -314,10 +311,8 @@ for (int i = 0; i < 10; i++) {

</div>


<div id="high-level-style-insert-data">


### Insert data
Write data with POJO objects:

```java
Expand All @@ -336,9 +331,8 @@ if (result.isOk()) {

</div>


<div id="high-level-style-streaming-insert">

### Streaming insert
```java
StreamWriter<List<?>, WriteOk> writer = greptimeDB.objectsStreamWriter();

Expand All @@ -363,7 +357,7 @@ LOG.info("Write result: {}", result);
</div>

<div id="ingester-json-type">

## Insert data in JSON type
In the [low-level API](#low-level-api),
you can specify the column type as `DataType.Json` using the `addField` method to add a JSON column.
Then use map to insert JSON data.
Expand Down Expand Up @@ -414,24 +408,21 @@ sensor.setAttributes(attr);
</div>

<div id="ingester-lib-debug-logs">

## Debug logs

The ingester SDK provides metrics and logs for debugging.
Please refer to [Metrics & Display](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/docs/metrics-display.md) and [Magic Tools](https://github.com/GreptimeTeam/greptimedb-ingester-java/blob/main/docs/magic-tools.md) to learn how to enable or disable the logs.

</div>

<div id="ingester-lib-reference">

## Ingester library reference
- [API Documentation](https://javadoc.io/doc/io.greptime/ingester-protocol/latest/index.html)

</div>

<div id="faq">

## FAQ
### Why am I getting some connection exceptions?

When using the GreptimeDB Java ingester SDK, you may encounter some connection exceptions.
For example, exceptions that are "`Caused by: java.nio.channels.UnsupportedAddressTypeException`",
"`Caused by: java.net.ConnectException: connect(..) failed: Address family not supported by protocol`", or
Expand Down Expand Up @@ -486,4 +477,4 @@ packaged into the final JAR, during the assembling process. So the fix can be:

</div>

</DocTemplate>
</DocTemplate>
Loading