shad-go/retryupdate/kvapi/api.go

38 lines
692 B
Go
Raw Normal View History

2022-02-10 22:06:57 +00:00
//go:build !change
2020-03-07 19:14:49 +00:00
// +build !change
package kvapi
import "github.com/gofrs/uuid"
type (
Client interface {
// Get the value of key.
Get(req *GetRequest) (*GetResponse, error)
// Set key to hold given value.
Set(rsp *SetRequest) (*SetResponse, error)
}
GetRequest struct {
Key string
}
GetResponse struct {
Value string
Version uuid.UUID
}
SetRequest struct {
Key, Value string
// OldVersion field is checked before updating value.
//
// When updating old value, OldVersion must specify uuid of currently stored value.
// When creating new value, OldVersion must hold zero value of UUID.
OldVersion, NewVersion uuid.UUID
}
SetResponse struct{}
)