chore: import upstream snapshot with attribution
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
govulncheck / govulncheck (push) Has been cancelled
Lint / golangci-lint (push) Has been cancelled
Run Tests / Unit Tests (push) Has been cancelled
Run Tests / Etcd Integration Tests (push) Has been cancelled
Harness (E2E) / Harnesses (mock LLM) (push) Has been cancelled
Harness (E2E) / Provider harnesses (live LLM conformance) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
# State with Postgres Store
|
||||
|
||||
Use the Postgres store for persistent key/value state.
|
||||
|
||||
## In code
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"go-micro.dev/v6"
|
||||
"go-micro.dev/v6/store"
|
||||
postgres "go-micro.dev/v6/store/postgres"
|
||||
)
|
||||
|
||||
func main() {
|
||||
st := postgres.NewStore()
|
||||
svc := micro.NewService("postgres-store", micro.Store(st))
|
||||
svc.Init()
|
||||
|
||||
_ = store.Write(&store.Record{Key: "foo", Value: []byte("bar")})
|
||||
recs, _ := store.Read("foo")
|
||||
log.Println("value:", string(recs[0].Value))
|
||||
|
||||
svc.Run()
|
||||
}
|
||||
```
|
||||
|
||||
## Via environment
|
||||
|
||||
Run your service with env vars set:
|
||||
|
||||
```bash
|
||||
MICRO_STORE=postgres \
|
||||
MICRO_STORE_ADDRESS=postgres://user:pass@127.0.0.1:5432/postgres \
|
||||
MICRO_STORE_DATABASE=micro \
|
||||
MICRO_STORE_TABLE=micro \
|
||||
go run main.go
|
||||
```
|
||||
Reference in New Issue
Block a user