Skip to content
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

feat: support InsertsRequest #81

Merged
merged 3 commits into from
Jun 5, 2023
Merged
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
45 changes: 25 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,28 @@ go get github.com/GreptimeTeam/greptimedb-client-go

## Example

you can visit [Example][example] for usage details.
you can visit [Documentation][document] for usage details and documentation,

## Usage

#### Datatype Supported

- int32
- int64
- int (as int64)
- uint32
- uint64
- uint (as uint64)
- float32
- float64
- int8, int16, int32, int64, int
- uint8, uint16, uint32, uint64, uint
- float32, float64
- bool
- []byte
- string
- time.Time
- int8, int16 (as int32) // not recommended
- uint8, uint16 (as uint32) // not recommended

#### Precision for Timestamp
#### Timestamp

The default precision is `Millisecond`, you can set a different precision,
once the precision is set, you can not change it anymore.
you can customize timestamp index via calling methods of [Metric][metric_doc]

##### precision

The default timestamp column precision is `Millisecond`, you can set a different precision.
And once the precision is setted, you can not change it any more.

- time.Second
- time.Millisecond
Expand All @@ -49,22 +46,30 @@ once the precision is set, you can not change it anymore.
metric.SetTimePrecision(time.Microsecond)
```

#### Stream Insert
##### alias

You can send several insert request by `Send()` and notify DB no more messages by `CloseAndRecv()`
The default timestamp column name is `ts`, if you want to use another name, you
can change it:

you can visit [stream_client_test.go](stream_client_test.go) for details
```go
metric.SetTimestampAlias("timestamp")
```

#### Prometheus

We also support querying with RangePromql and Promql(TODO).
How to query with RangePromql and Promql, you can visit [promql_test.go](query_promql_test.go) for details

#### Stream Insert

You can send several insert requests by `Send()` and notify GreptimeDB no more messages by `CloseAndRecv()`

you can visit [promql_test.go](promql_test.go) for details
You can visit [stream_client_test.go](stream_client_test.go) for details

## License

This greptimedb-client-go uses the __Apache 2.0 license__ to strike a balance
between open contributions and allowing you to use the software however you want.

<!-- links -->
[example]: https://pkg.go.dev/github.com/GreptimeTeam/greptimedb-client-go#example-package
[document]: https://pkg.go.dev/github.com/GreptimeTeam/greptimedb-client-go
[metric_doc]: https://pkg.go.dev/github.com/GreptimeTeam/greptimedb-client-go#Metric
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func NewClient(cfg *Config) (*Client, error) {
}, nil
}

// Insert helps to insert multiple rows into greptimedb
func (c *Client) Insert(ctx context.Context, req InsertRequest) (uint32, error) {
// Insert helps to insert multiple rows of multiple tables into greptimedb
func (c *Client) Insert(ctx context.Context, req InsertsRequest) (uint32, error) {
request, err := req.build(c.cfg)
if err != nil {
return 0, err
Expand Down
Loading