Skip to content

Commit 407b132

Browse files
authored
docs: ref to Interact with Oxia by Go client (oxia-db#328)
This closes oxia-db#317. --------- Signed-off-by: tison <[email protected]>
1 parent dcdd34b commit 407b132

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

docs/getting-started.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
21
# Getting started with Oxia
32

4-
53
## Obtaining Oxia
64

7-
## Docker image
5+
### Docker image
86

97
Oxia is available in form of a Docker image
108

119
```shell
1210
$ docker pull streamnative/oxia:main
1311
```
1412

15-
## Building from source
13+
### Building from source
1614

1715
```shell
1816
$ make
@@ -47,11 +45,10 @@ The service is now ready at `localhost:6648` address.
4745
Using docker this can be done with:
4846

4947
```shell
50-
$ docker run -p 6648:6648 streamnative/oxia:main oxia standalone
48+
$ docker run -p 6648:6648 streamnative/oxia:main oxia standalone
5149
```
5250

53-
54-
## Using Oxia CLI client
51+
## Interacting by CLI
5552

5653
There is a convenient CLI tool that allows you to interact with the records stored in Oxia.
5754

@@ -66,9 +63,13 @@ $ oxia client get -k /my-key
6663
{"binary":false,"value":"my-value","version":{"version_id":0,"created_timestamp":1680220430128,"modified_timestamp":1680220430128,"modifications_count":0}}
6764
```
6865

66+
## Interacting by Go client
67+
68+
Instead, you can write a Go application with [Oxia Go API](go-api.md).
69+
6970
## Using perf client
7071

71-
If you want to do a quick assessment of the capacity of an Oxia cluster, you can use the provided `perf` tool, which
72+
If you want to do a quick assessment of the capacity of an Oxia cluster, you can use the provided `perf` tool, which
7273
generates some amount of traffic, based on the desired rate and read/write ratio.
7374

7475

docs/go-api.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# Oxia Go client API
22

3-
The full GoDoc reference for the Oxia Go Client can be found at https://pkg.go.dev/github.com/streamnative/oxia/oxia
3+
The full GoDoc reference for the Oxia Go client can be found at: https://pkg.go.dev/github.com/streamnative/oxia/oxia.
44

55
A simple example on how to write and read records:
66

77
```go
88
// import "github.com/streamnative/oxia/oxia"
99

10-
1110
client, err := oxia.NewSyncClient("localhost:6648")
1211
if err != nil {
1312
return err
@@ -36,7 +35,6 @@ Oxia also provides an "async" client API that makes use of channels to track the
3635
With the async client API, a single go-routine can submit many concurrent requests. In addition, the Oxia client library
3736
will automatically batch the request for better performance.
3837

39-
4038
```go
4139
client, err := oxia.NewAsyncClient("localhost:6648",
4240
oxia.WithBatchLinger(10*time.Millisecond))
@@ -56,7 +54,6 @@ if res := <-c3; res.Err != nil {
5654
}
5755
```
5856

59-
6057
## Namespaces
6158

6259
A client can use a particular Oxia namespace, other than `default`, by specifying an option in the client instantiation:
@@ -74,7 +71,6 @@ Client can subscribe to receive a feed of notification with all the events happe
7471
Notifications can be used to replicate exactly the state of an oxia namespace or to invalidate a cache.
7572

7673
```go
77-
7874
client, err := oxia.NewSyncClient("localhost:6648")
7975
notifications, err := client.GetNotifications()
8076
if err != nil {
@@ -114,7 +110,7 @@ appropriately with `oxia.WithSessionTimeout()` option when creating the client i
114110

115111
Oxia client provides a built-in optional cache that will store the deserialized values.
116112

117-
Example:
113+
Example:
118114

119115
```go
120116
type myStruct struct {
@@ -134,9 +130,9 @@ value, version, err := cache.Get(context.Background(), "/my-key")
134130
fmt.Printf("A: %s - B: %d\n", value.A, value.B)
135131

136132
// We can also do atomic read-modify-updates through the cache
137-
// This will not incur in a read from the server if the value is already
133+
// This will not incur in a read from the server if the value is already
138134
// in cache and up to the latest version
139-
err = cache.ReadModifyUpdate(context.Background(), "/my-key",
135+
err = cache.ReadModifyUpdate(context.Background(), "/my-key",
140136
func(existingValue Optional[myStruct]) (myStruct, error) {
141137
return myStruct{
142138
A: existingValue.MustGet().A,
@@ -149,6 +145,5 @@ err = cache.ReadModifyUpdate(context.Background(), "/my-key",
149145

150146
The cache is kept up to date using Oxia notification, to invalidate whenever a record is updated.
151147

152-
Change don through the cache are also immediately reflected in the cache. For updates done outside the cache instance,
148+
Change don through the cache are also immediately reflected in the cache. For updates done outside the cache instance,
153149
the cache will be eventually consistent, meaning that a cache read could return a stale value for a short amount of time.
154-

0 commit comments

Comments
 (0)