Skip to content

Commit

Permalink
docs: add async write
Browse files Browse the repository at this point in the history
  • Loading branch information
killme2008 committed Dec 1, 2023
1 parent 066ea9a commit 2caf6c2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ Write data by rows:
greptimedb:write(Client, Metric, Points).
```

Write in async:

```erlang
Ref = make_ref(),
Pid = self(),
ResultCallback = {fun(Reply) -> Pid ! {{Ref, reply}, Reply} end, []},

ok = greptimedb:async_write(Client, Metric, Points, ResultCallback),
receive
{{Ref, reply}, Reply} ->
io:format("Reply ~w~n", [Reply])
end.
```

Batch write:

```erlang
Metric1 = <<"temperatures">>,
Points1 = [...],
Expand All @@ -64,6 +79,21 @@ Batch = [{Metric1, Points1}, {Metric2, Points}],
{ok, _} = greptimedb:write_batch(Client, Batch).
```

Batch write in async:

```erlang
Batch = ...,
Ref = make_ref(),
Pid = self(),
ResultCallback = {fun(Reply) -> Pid ! {{Ref, reply}, Reply} end, []},

ok = greptimedb:async_write_batch(Client, Batch, ResultCallback),
receive
{{Ref, reply}, Reply} ->
io:format("Reply ~w~n", [Reply])
end.
```

Streaming write:

```erlang
Expand Down

0 comments on commit 2caf6c2

Please sign in to comment.