feat: add K2V_ENDPOINT env var
This commit is contained in:
parent
97bedfe1aa
commit
231423cd0b
3 changed files with 20 additions and 6 deletions
17
README.md
17
README.md
|
@ -11,11 +11,14 @@ import k2v "code.notaphish.fyi/milas/garage-k2v-go"
|
|||
|
||||
## Create API client
|
||||
```go
|
||||
endpoint := "http://localhost:3904"
|
||||
// Read K2V_ENDPOINT from OS environment variable, e.g. http://localhost:3904.
|
||||
endpoint := k2v.EndpointFromEnv()
|
||||
|
||||
// Read K2V_KEY_ID and K2V_SECRET_KEY from OS environment variables.
|
||||
// Read K2V_KEY_ID and K2V_KEY_SECRET from OS environment variables.
|
||||
key := k2v.KeyFromEnv()
|
||||
// key := k2v.Key{ID: "GK49e661847883e4813993a0db", Secret: "..."}
|
||||
|
||||
// Alternatively, construct a key by initializing the ID and secret fields on a k2v.Key.
|
||||
// key := k2v.Key{ID: "GK...", Secret: "..."}
|
||||
|
||||
client := k2v.NewClient(endpoint, key)
|
||||
```
|
||||
|
@ -36,6 +39,14 @@ type Client
|
|||
func (c *Client) ReadItemSingle(ctx context.Context, b Bucket, pk string, sk string) (Item, CausalityToken, error)
|
||||
```
|
||||
|
||||
## Integration Tests
|
||||
```shell
|
||||
K2V_ENDPOINT="http://[::1]:3904" \
|
||||
K2V_KEY_ID="GK..." \
|
||||
K2V_KEY_SECRET="..." \
|
||||
go test ./...
|
||||
```
|
||||
|
||||
## Usage
|
||||
Review the [K2V API spec][k2v-api] and the integration tests in this module for complete examples.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue