Documentation ¶
Overview ¶
Package client implements the official Go regatta client.
Create client using `client.New`:
// expect dial time-out on blackhole address _, err := client.New(client.ConfigSpec{ Endpoints: []string{"http://254.0.0.1:12345"}, DialTimeout: 2 * time.Second, }) if err == context.DeadlineExceeded { // handle errors } cli, err := client.New(client.ConfigSpec{ Endpoints: []string{"localhost:2379", "localhost:22379", "localhost:32379"}, DialTimeout: 5 * time.Second, }) if err != nil { // handle error! } defer cli.Close()
Make sure to close the client after using it. If the client is not closed, the connection will have leaky goroutines.
To specify a client request timeout, wrap the context with context.WithTimeout:
ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() resp, err := kvc.Table("table).Put(ctx, "key", "sample_value") if err != nil { // handle error! } // use the response
The Client has internal state, so Clients should be reused instead of created as needed. Clients are safe for concurrent use by multiple goroutines.
Index ¶
- Variables
- func ErrorDesc(err error) string
- func GetPrefixRangeEnd(prefix string) string
- func IsConnCanceled(err error) bool
- func IsOptsWithFromKey(opts []OpOption) bool
- func IsOptsWithPrefix(opts []OpOption) bool
- func WithRequireLeader(ctx context.Context) context.Context
- type Client
- func (c *Client) ActiveConnection() *grpc.ClientConn
- func (c *Client) Close() error
- func (c *Client) Ctx() context.Context
- func (c *Client) Dial(ep string) (*grpc.ClientConn, error)
- func (c *Client) Endpoints() []string
- func (c *Client) HandleConn(ctx context.Context, stats stats.ConnStats)
- func (c *Client) HandleRPC(ctx context.Context, stats stats.RPCStats)
- func (c *Client) SetEndpoints(eps ...string)
- func (c *Client) SetLogger(lg Logger) *Client
- func (c *Client) Sync(ctx context.Context) error
- func (c *Client) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context
- func (c *Client) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context
- type Cluster
- type Cmp
- type CompareResult
- type CompareTarget
- type CreateTableResponse
- type DeleteResponse
- type DeleteTableResponse
- type FakeClient
- type FakeResponse
- type GetResponse
- type Hook
- type HookClientClosed
- type HookHandleConn
- type HookHandleRPC
- type HookKVOpDo
- type HookNewClient
- type IteratorResponse
- type KV
- type KeyValue
- type KvDo
- type ListTablesResponse
- type Logger
- type Member
- type MemberListResponse
- type NoOpLogger
- type Op
- func (op *Op) IsCountOnly() bool
- func (op *Op) IsDelete() bool
- func (op *Op) IsGet() bool
- func (op *Op) IsIterate() bool
- func (op *Op) IsKeysOnly() bool
- func (op *Op) IsPut() bool
- func (op *Op) IsSerializable() bool
- func (op *Op) IsTxn() bool
- func (op *Op) KeyBytes() []byte
- func (op *Op) RangeBytes() []byte
- func (op *Op) Rev() int64
- func (op *Op) Txn() ([]Cmp, []Op, []Op)
- func (op *Op) ValueBytes() []byte
- func (op *Op) WithKeyBytes(key []byte)
- func (op *Op) WithRangeBytes(end []byte)
- func (op *Op) WithValueBytes(v []byte)
- type OpOption
- func WithCount() OpOption
- func WithCountOnly() OpOption
- func WithFromKey() OpOption
- func WithKeysOnly() OpOption
- func WithLimit(n int64) OpOption
- func WithPrefix() OpOption
- func WithPrevKV() OpOption
- func WithRange(endKey string) OpOption
- func WithRev(rev int64) OpOption
- func WithSerializable() OpOption
- type OpResponse
- type Option
- func WithAutoSyncInterval(interval time.Duration) Option
- func WithBlock() Option
- func WithDialOptions(dial ...grpc.DialOption) Option
- func WithDialTimeout(t time.Duration) Option
- func WithEndpoints(endpoints ...string) Option
- func WithHooks(hooks ...Hook) Option
- func WithKeepalive(keepaliveTime, keepaliveTimeout time.Duration) Option
- func WithLogger(logger Logger) Option
- func WithMaxCallRecvMsgSize(max int) Option
- func WithMaxCallSendMsgSize(max int) Option
- func WithRejectOldCluster(roc bool) Option
- func WithReturnConnectionError() Option
- func WithSecureConfig(sc *SecureConfig) Option
- type PrintLogger
- type PutResponse
- type RecordedRequest
- type ResponseHeader
- type ResponseOp
- type ResponseOpDeleteRange
- type ResponseOpPut
- type ResponseOpRange
- type SecureConfig
- type StatusResponse
- type TLSInfo
- type Table
- type TableInfo
- type TableStatus
- type Tables
- type Txn
- type TxnResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoAvailableEndpoints = errors.New("regattaclient: no available endpoints") ErrOldCluster = errors.New("regattaclient: old cluster version") )
var ( MetadataRequireLeaderKey = "has-leader" MetadataClientAPIVersionKey = "client-api-version" MetadataHasLeader = "true" )
var Version = "unknown"
Functions ¶
func GetPrefixRangeEnd ¶
GetPrefixRangeEnd gets the range end of the prefix. 'Get(foo, WithPrefix())' is equal to 'Get(foo, WithRange(GetPrefixRangeEnd(foo))'.
func IsConnCanceled ¶
IsConnCanceled returns true, if error is from a closed gRPC connection. ref. https://github.com/grpc/grpc-go/pull/1854
func IsOptsWithFromKey ¶
IsOptsWithFromKey returns true if WithFromKey option is called in the given opts.
func IsOptsWithPrefix ¶
IsOptsWithPrefix returns true if WithPrefix option is called in the given opts.
Types ¶
type Client ¶
Client provides and manages an regatta client session.
func NewFromURL ¶
NewFromURL creates a new regatta client from a URL.
func NewFromURLs ¶
NewFromURLs creates a new regatta client from URLs.
func (*Client) ActiveConnection ¶
func (c *Client) ActiveConnection() *grpc.ClientConn
ActiveConnection returns the current in-use connection.
func (*Client) Ctx ¶
Ctx is a context for "out of band" messages (e.g., for sending "clean up" message when another context is canceled). It is canceled on client Close().
func (*Client) Dial ¶
func (c *Client) Dial(ep string) (*grpc.ClientConn, error)
Dial connects to a single endpoint using the client's config.
func (*Client) SetEndpoints ¶
SetEndpoints updates client's endpoints.
func (*Client) SetLogger ¶
SetLogger overrides the logger. Does not change grpcLogger, that can be explicitly configured using grpc_zap.ReplaceGrpcLoggerV2(..) method.
func (*Client) Sync ¶
Sync synchronizes client's endpoints with the known endpoints from the regatta membership.
type Cluster ¶
type Cluster interface { // MemberList lists the current cluster membership. MemberList(ctx context.Context) (*MemberListResponse, error) // Status gets the status of the endpoint. Status(ctx context.Context, endpoint string) (*StatusResponse, error) }
type Cmp ¶
type Cmp struct {
*regattapb.Compare
}
func (Cmp) ValueBytes ¶
ValueBytes returns the byte slice holding the comparison value, if any.
func (Cmp) WithKeyBytes ¶
WithKeyBytes sets the byte slice for the comparison key.
func (Cmp) WithPrefix ¶
WithPrefix sets the comparison to scan all keys prefixed by the key.
func (Cmp) WithValueBytes ¶
WithValueBytes sets the byte slice for the comparison's value.
type CompareResult ¶
type CompareResult int
type CompareTarget ¶
type CompareTarget int
const ( CompareVersion CompareTarget = iota CompareCreated CompareModified CompareValue )
type CreateTableResponse ¶ added in v0.4.0
type CreateTableResponse regattapb.CreateTableResponse
func (*CreateTableResponse) String ¶ added in v0.4.0
func (resp *CreateTableResponse) String() string
type DeleteResponse ¶
type DeleteResponse struct { Header *ResponseHeader `json:"header,omitempty"` // deleted is the number of keys deleted by the delete range request. Deleted int64 `json:"deleted,omitempty"` // if prev_kv is set in the request, the previous key-value pairs will be returned. PrevKvs []*KeyValue `json:"prev_kvs,omitempty"` }
func (*DeleteResponse) OpResponse ¶
func (resp *DeleteResponse) OpResponse() OpResponse
func (*DeleteResponse) String ¶ added in v0.0.2
func (resp *DeleteResponse) String() string
type DeleteTableResponse ¶ added in v0.4.0
type DeleteTableResponse regattapb.DeleteTableResponse
type FakeClient ¶ added in v0.1.3
type FakeClient struct {
// contains filtered or unexported fields
}
FakeClient provides a fake regatta client. This client is intended to be used only in tests.
func NewFake ¶ added in v0.1.3
func NewFake(fakeResponses ...FakeResponse) (*FakeClient, context.CancelFunc)
NewFake creates an instance of FakeClient, including a function for client termination.
func (*FakeClient) Client ¶ added in v0.1.3
func (c *FakeClient) Client() *Client
Client returns a new instance of regatta client targeting the fake regatta server.
func (*FakeClient) RecordedRequests ¶ added in v0.2.2
func (c *FakeClient) RecordedRequests() []RecordedRequest
type FakeResponse ¶ added in v0.1.3
type FakeResponse struct { Response OpResponse Err error }
FakeResponse holds response fields returned by the fake client.
type GetResponse ¶
type GetResponse struct { Header *ResponseHeader `json:"header,omitempty"` // kvs is the list of key-value pairs matched by the range request. // kvs is empty when count is requested. Kvs []*KeyValue `json:"kvs,omitempty"` // more indicates if there are more keys to return in the requested range. More bool `json:"more,omitempty"` // count is set to the number of keys within the range when requested. Count int64 `json:"count,omitempty"` }
func (*GetResponse) OpResponse ¶
func (resp *GetResponse) OpResponse() OpResponse
func (*GetResponse) String ¶ added in v0.0.2
func (resp *GetResponse) String() string
type Hook ¶
type Hook any
Hook is a hook to be called when something happens in regatta-go.
The base Hook interface is useless, but wherever a hook can occur in kgo, the client checks if your hook implements an appropriate interface. If so, your hook is called.
This allows you to only hook in to behavior you care about, and it allows the client to add more hooks in the future.
All hook interfaces in this package have Hook in the name. Hooks must be safe for concurrent use. It is expected that hooks are fast; if a hook needs to take time, then copy what you need and ensure the hook is async.
type HookClientClosed ¶
type HookClientClosed interface { // OnClientClosed is passed the client that has been closed, after // all client-internal close cleanup has happened. OnClientClosed(*Client) }
HookClientClosed is called in Close after a client has been closed. This hook can be used to perform final cleanup work.
type HookHandleConn ¶
HookHandleConn is called whenever connection is changed (connected/disconnected/errored). the provided stats could be of various types, check implementation of stats.ConnStats interface.
type HookHandleRPC ¶
HookHandleRPC is called whenever any RPC is made by the client. the provided stats could be of various types, check implementation of stats.RPCStats interface.
type HookKVOpDo ¶ added in v0.0.2
type HookNewClient ¶
type HookNewClient interface { // OnNewClient is passed the newly initialized client, before any // client goroutines are started. OnNewClient(*Client) }
HookNewClient is called in NewClient after a client is initialized. This hook can be used to perform final setup work in your hooks.
type IteratorResponse ¶ added in v0.3.0
type IteratorResponse func(yield func(response *GetResponse, err error) bool)
func (IteratorResponse) OpResponse ¶ added in v0.3.1
func (resp IteratorResponse) OpResponse() OpResponse
type KV ¶
type KV interface { // Put puts a key-value pair into regatta. // Note that key,value can be plain bytes array and string is // an immutable representation of that bytes array. // To get a string of bytes, do string([]byte{0x10, 0x20}). Put(ctx context.Context, table, key, val string, opts ...OpOption) (*PutResponse, error) // Get retrieves keys. // By default, Get will return the value for "key", if any. // When passed WithRange(end), Get will return the keys in the range [key, end). // When passed WithFromKey(), Get returns keys greater than or equal to key. // When passed key "" and WithFromKey(), Get returns all keys. // When passed WithRev(rev) with rev > 0, Get retrieves keys at the given revision; // if the required revision is compacted, the request will fail with ErrCompacted . // When passed WithLimit(limit), the number of returned keys is bounded by limit. // When passed WithSort(), the keys will be sorted. // Note that a single response is limited by a max size of ~4MiB. If more keys in the range exists the GetResponse.More will be set to true. Get(ctx context.Context, table, key string, opts ...OpOption) (*GetResponse, error) // Iterate retrieves keys in iterator fashion, use this if you expect that the dataset returned will be larger than 4MiB. // Iterator runs until exhaustion or until the callback func returns false. // By default, Iterate will return the value for "key", if any. // When passed WithRange(end), Iterate will return the keys in the range [key, end). // When passed WithFromKey(), Iterate returns keys greater than or equal to key. // When passed key "" and WithFromKey(), Iterate returns all keys. // When passed WithRev(rev) with rev > 0, Iterate retrieves keys at the given revision; // if the required revision is compacted, the request will fail with ErrCompacted . // When passed WithLimit(limit), the number of returned keys is bounded by limit. // When passed WithSort(), the keys will be sorted. Iterate(ctx context.Context, table, key string, opts ...OpOption) (IteratorResponse, error) // Delete deletes a key, or optionally using WithRange(end), [key, end). Delete(ctx context.Context, table, key string, opts ...OpOption) (*DeleteResponse, error) // Do apply a single Op on KV without a transaction. // Do is useful when creating arbitrary operations to be issued at a // later time; the user can range over the operations, calling Do to // execute them. Get/Put/Delete, on the other hand, are best suited // for when the operation should be issued at the time of declaration. Do(ctx context.Context, table string, op Op) (OpResponse, error) // Table is a convenience function that provides requests scoped to a single table. Table(name string) Table // Txn creates a transaction. Txn(ctx context.Context, table string) Txn }
type ListTablesResponse ¶ added in v0.4.0
type ListTablesResponse struct {
Tables []TableInfo
}
func (*ListTablesResponse) String ¶ added in v0.4.0
func (resp *ListTablesResponse) String() string
type MemberListResponse ¶
type MemberListResponse regattapb.MemberListResponse
type NoOpLogger ¶ added in v0.0.3
type NoOpLogger struct{}
func (NoOpLogger) Debugf ¶ added in v0.0.3
func (n NoOpLogger) Debugf(s string, a ...any)
func (NoOpLogger) Errorf ¶ added in v0.0.3
func (n NoOpLogger) Errorf(s string, a ...any)
func (NoOpLogger) Infof ¶ added in v0.0.3
func (n NoOpLogger) Infof(s string, a ...any)
func (NoOpLogger) Warnf ¶ added in v0.0.3
func (n NoOpLogger) Warnf(s string, a ...any)
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents an Operation that kv can execute.
func (*Op) IsCountOnly ¶
IsCountOnly returns whether countOnly is set.
func (*Op) IsSerializable ¶
IsSerializable returns true if the serializable field is true.
func (*Op) RangeBytes ¶
RangeBytes returns the byte slice holding with the Op's range end, if any.
func (*Op) Txn ¶
Txn returns the comparison(if) operations, "then" operations, and "else" operations.
func (*Op) ValueBytes ¶
ValueBytes returns the byte slice holding the Op's value, if any.
func (*Op) WithKeyBytes ¶
WithKeyBytes sets the byte slice for the Op's key.
func (*Op) WithRangeBytes ¶
WithRangeBytes sets the byte slice for the Op's range end.
func (*Op) WithValueBytes ¶
WithValueBytes sets the byte slice for the Op's value.
type OpOption ¶
type OpOption func(*Op)
OpOption configures Operations like Get, Put, Delete.
func WithCount ¶ added in v0.1.5
func WithCount() OpOption
WithCount makes the 'Delete' request return also count of deleted key-value pairs.
func WithCountOnly ¶
func WithCountOnly() OpOption
WithCountOnly makes the 'Get' request return only the count of keys.
func WithFromKey ¶
func WithFromKey() OpOption
WithFromKey specifies the range of 'Get', 'Delete', 'Watch' requests to be equal or greater than the key in the argument.
func WithKeysOnly ¶
func WithKeysOnly() OpOption
WithKeysOnly makes the 'Get' request return only the keys and the corresponding values will be omitted.
func WithLimit ¶
WithLimit limits the number of results to return from 'Get' request. If WithLimit is given a 0 limit, it is treated as no limit.
func WithPrefix ¶
func WithPrefix() OpOption
WithPrefix enables 'Get', 'Delete', or 'Watch' requests to operate on the keys with matching prefix. For example, 'Get(foo, WithPrefix())' can return 'foo1', 'foo2', and so on.
func WithPrevKV ¶
func WithPrevKV() OpOption
WithPrevKV gets the previous key-value pair before the event happens. If the previous KV is already compacted, nothing will be returned.
func WithRange ¶
WithRange specifies the range of 'Get', 'Delete', 'Watch' requests. For example, 'Get' requests with 'WithRange(end)' returns the keys in the range [key, end). endKey must be lexicographically greater than start key.
func WithRev ¶
WithRev specifies the store revision for 'Get' request. Or the start revision of 'Watch' request.
func WithSerializable ¶
func WithSerializable() OpOption
WithSerializable makes 'Get' request serializable. By default, it's linearizable. Serializable requests are better for lower latency requirement.
type OpResponse ¶
type OpResponse struct {
// contains filtered or unexported fields
}
func (OpResponse) Del ¶
func (op OpResponse) Del() *DeleteResponse
func (OpResponse) Get ¶
func (op OpResponse) Get() *GetResponse
func (OpResponse) Iterate ¶ added in v0.3.0
func (op OpResponse) Iterate() IteratorResponse
func (OpResponse) Put ¶
func (op OpResponse) Put() *PutResponse
func (OpResponse) Txn ¶
func (op OpResponse) Txn() *TxnResponse
type Option ¶
type Option func(config *config)
Option is a function type that can be passed as argument to New to configure client.
func WithAutoSyncInterval ¶ added in v0.0.3
WithAutoSyncInterval is the interval to update endpoints with its latest members. 0 disables auto-sync. By default, auto-sync is disabled.
func WithBlock ¶ added in v0.1.0
func WithBlock() Option
WithBlock returns a DialOption which makes callers of Dial block until the underlying connection is up. Without this, Dial returns immediately and connecting the server happens in background. Use of this feature is not recommended. For more information, please see: https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
func WithDialOptions ¶ added in v0.0.3
func WithDialOptions(dial ...grpc.DialOption) Option
WithDialOptions sets the list of dial options for the grpc client (e.g., for interceptors). For example, pass "grpc.WithBlock()" to block until the underlying connection is up. Without this, Dial returns immediately and connecting the server happens in background.
func WithDialTimeout ¶ added in v0.1.0
WithDialTimeout sets the dial timeout.
func WithEndpoints ¶ added in v0.0.3
WithEndpoints sets the list of seed URLs.
func WithHooks ¶ added in v0.0.3
WithHooks sets plugin hooks, check the plugin directory for available plugin modules.
func WithKeepalive ¶ added in v0.1.0
WithKeepalive sets the keepalive protocol timeouts, keepaliveTime is the time after which client pings the server to see if transport is alive. keepaliveTimeout is the time that the client waits for a response for the keep-alive probe. If the response is not received in this time, the connection is closed.
func WithLogger ¶
WithLogger sets client-side logger. Defaults to NOOp logger.
func WithMaxCallRecvMsgSize ¶ added in v0.0.3
WithMaxCallRecvMsgSize sets the client-side response receive limit. If 0, it defaults to "math.MaxInt32", because range response can easily exceed request send limits. Make sure that "MaxCallRecvMsgSize" >= server-side default send/recv limit. ("--api.max-recv-bytes" flag to regatta).
func WithMaxCallSendMsgSize ¶ added in v0.0.3
WithMaxCallSendMsgSize sets the client-side request send limit in bytes. If 0, it defaults to 2.0 MiB (2 * 1024 * 1024). Make sure that "MaxCallSendMsgSize" < server-side default send/recv limit. ("--api.max-send-bytes" flag to regatta or "embed.Config.MaxRequestBytes").
func WithRejectOldCluster ¶ added in v0.0.3
WithRejectOldCluster set will refuse to create a client against an outdated cluster.
func WithReturnConnectionError ¶ added in v0.1.0
func WithReturnConnectionError() Option
WithReturnConnectionError returns a DialOption which makes the client connection return a string containing both the last connection error that occurred and the context.DeadlineExceeded error. Implies WithBlock().
func WithSecureConfig ¶ added in v0.0.3
func WithSecureConfig(sc *SecureConfig) Option
WithSecureConfig sets the TLS and related configs.
type PrintLogger ¶
type PrintLogger struct{}
func (PrintLogger) Debugf ¶
func (p PrintLogger) Debugf(s string, a ...any)
func (PrintLogger) Errorf ¶
func (p PrintLogger) Errorf(s string, a ...any)
func (PrintLogger) Infof ¶
func (p PrintLogger) Infof(s string, a ...any)
func (PrintLogger) Warnf ¶
func (p PrintLogger) Warnf(s string, a ...any)
type PutResponse ¶
type PutResponse struct { Header *ResponseHeader `json:"header,omitempty"` // if prev_kv is set in the request, the previous key-value pair will be returned. PrevKv *KeyValue `json:"prev_kv,omitempty"` }
func (*PutResponse) OpResponse ¶
func (resp *PutResponse) OpResponse() OpResponse
func (*PutResponse) String ¶ added in v0.0.2
func (resp *PutResponse) String() string
type RecordedRequest ¶ added in v0.2.2
RecordedRequest holds request fields recorded by the fake client.
type ResponseHeader ¶
type ResponseHeader regattapb.ResponseHeader
type ResponseOp ¶
type ResponseOp struct {
*regattapb.ResponseOp
}
func (*ResponseOp) GetResponseDeleteRange ¶ added in v0.3.0
func (x *ResponseOp) GetResponseDeleteRange() *ResponseOpDeleteRange
func (*ResponseOp) GetResponsePut ¶ added in v0.3.0
func (x *ResponseOp) GetResponsePut() *ResponseOpPut
func (*ResponseOp) GetResponseRange ¶ added in v0.3.0
func (x *ResponseOp) GetResponseRange() *ResponseOpRange
type ResponseOpDeleteRange ¶ added in v0.3.0
type ResponseOpDeleteRange regattapb.ResponseOp_DeleteRange
type ResponseOpPut ¶ added in v0.3.0
type ResponseOpPut regattapb.ResponseOp_Put
type ResponseOpRange ¶ added in v0.3.0
type ResponseOpRange regattapb.ResponseOp_Range
type SecureConfig ¶
type StatusResponse ¶
type StatusResponse struct { // Id is the member ID of this member. Id string // Version is the semver version used by the responding member. Version string // Info is the additional server info. Info string // Tables is a status of tables of the responding member. Tables map[string]*TableStatus // Errors contains alarm/health information and status. Errors []string // Config contains the member configuration. Config map[string]any }
StatusResponse represents response from Status API.
type TLSInfo ¶
type TLSInfo struct { // CertFile is the _server_ cert, it will also be used as a _client_ certificate if ClientCertFile is empty CertFile string // KeyFile is the key for the CertFile KeyFile string // ClientCertFile is a _client_ cert for initiating connections when ClientCertAuth is defined. If ClientCertAuth // is true but this value is empty, the CertFile will be used instead. ClientCertFile string // ClientKeyFile is the key for the ClientCertFile ClientKeyFile string TrustedCAFile string ClientCertAuth bool CRLFile string InsecureSkipVerify bool SkipClientSANVerify bool // ServerName ensures the cert matches the given host in case of discovery / virtual hosting ServerName string // HandshakeFailure is optionally called when a connection fails to handshake. The // connection will be closed immediately afterwards. HandshakeFailure func(*tls.Conn, error) // CipherSuites is a list of supported cipher suites. // If empty, Go auto-populates it by default. // Note that cipher suites are prioritized in the given order. CipherSuites []uint16 // AllowedCN is a CN which must be provided by a client. AllowedCN string // AllowedHostname is an IP address or hostname that must match the TLS // certificate provided by a client. AllowedHostname string // Logger logs TLS errors. // If nil, all logs are discarded. Logger Logger // EmptyCN indicates that the cert must have empty CN. // If true, ClientConfig() will return an error for a cert with non empty CN. EmptyCN bool // contains filtered or unexported fields }
func (TLSInfo) ClientConfig ¶
ClientConfig generates a tls.Config object for use by an HTTP client.
type Table ¶
type Table interface { // Put puts a key-value pair into regatta. // Note that key,value can be plain bytes array and string is // an immutable representation of that bytes array. // To get a string of bytes, do string([]byte{0x10, 0x20}). Put(ctx context.Context, key, val string, opts ...OpOption) (*PutResponse, error) // Get retrieves keys. // By default, Get will return the value for "key", if any. // When passed WithRange(end), Get will return the keys in the range [key, end). // When passed WithFromKey(), Get returns keys greater than or equal to key. // When passed WithRev(rev) with rev > 0, Get retrieves keys at the given revision; // if the required revision is compacted, the request will fail with ErrCompacted . // When passed WithLimit(limit), the number of returned keys is bounded by limit. // When passed WithSort(), the keys will be sorted. Get(ctx context.Context, key string, opts ...OpOption) (*GetResponse, error) // Iterate retrieves keys in iterator fashion, use this if you expect that the dataset returned will be larger than 4MiB. // Iterator runs until exhaustion or until the callback func returns false. // By default, Iterate will return the value for "key", if any. // When passed WithRange(end), Iterate will return the keys in the range [key, end). // When passed WithFromKey(), Iterate returns keys greater than or equal to key. // When passed key "" and WithFromKey(), Iterate returns all keys. // When passed WithRev(rev) with rev > 0, Iterate retrieves keys at the given revision; // if the required revision is compacted, the request will fail with ErrCompacted . // When passed WithLimit(limit), the number of returned keys is bounded by limit. // When passed WithSort(), the keys will be sorted. Iterate(ctx context.Context, key string, opts ...OpOption) (IteratorResponse, error) // Delete deletes a key, or optionally using WithRange(end), [key, end). Delete(ctx context.Context, key string, opts ...OpOption) (*DeleteResponse, error) // Txn creates a transaction. Txn(ctx context.Context) Txn }
type TableStatus ¶ added in v0.2.1
type TableStatus regattapb.TableStatus
type Tables ¶ added in v0.4.0
type Tables interface { // CreateTable creates table with specified name. CreateTable(ctx context.Context, name string) (*CreateTableResponse, error) // DeleteTable gets the status of the endpoint. DeleteTable(ctx context.Context, name string) (*DeleteTableResponse, error) // ListTables lists all currently registered tables. ListTables(ctx context.Context) (*ListTablesResponse, error) }
func NewTablesFromTablesClient ¶ added in v0.4.0
type Txn ¶
type Txn interface { // If takes a list of comparison. If all comparisons passed in succeed, // the operations passed into Then() will be executed. Or the operations // passed into Else() will be executed. If(cs ...Cmp) Txn // Then takes a list of operations. The Ops list will be executed, if the // comparisons passed in If() succeed. Then(ops ...Op) Txn // Else takes a list of operations. The Ops list will be executed, if the // comparisons passed in If() fail. Else(ops ...Op) Txn // Commit tries to commit the transaction. Commit() (*TxnResponse, error) }
type TxnResponse ¶
type TxnResponse struct { Header *ResponseHeader `json:"header,omitempty"` // succeeded is set to true if the compare evaluated to true or false otherwise. Succeeded bool `json:"succeeded,omitempty"` // responses is a list of responses corresponding to the results from applying // success if succeeded is true or failure if succeeded is false. Responses []*ResponseOp `json:"responses,omitempty"` }
func (*TxnResponse) OpResponse ¶
func (resp *TxnResponse) OpResponse() OpResponse
func (*TxnResponse) String ¶ added in v0.0.2
func (resp *TxnResponse) String() string