Documentation ¶
Index ¶
- Variables
- func DecodeDb(response *Message) (id uint32, err error)
- func DecodeEmpty(response *Message) (err error)
- func DecodeFailure(response *Message) (code uint64, message string, err error)
- func DecodeServer(response *Message) (address string, err error)
- func DecodeStmt(response *Message) (db uint32, id uint32, params uint64, err error)
- func DecodeWelcome(response *Message) (heartbeatTimeout uint64, err error)
- func EncodeClient(request *Message, id uint64)
- func EncodeExec(request *Message, db uint32, stmt uint32, values NamedValues)
- func EncodeExecSQL(request *Message, db uint64, sql string, values NamedValues)
- func EncodeFinalize(request *Message, db uint32, stmt uint32)
- func EncodeHeartbeat(request *Message, timestamp uint64)
- func EncodeInterrupt(request *Message, db uint64)
- func EncodeJoin(request *Message, id uint64, address string)
- func EncodeLeader(request *Message)
- func EncodeOpen(request *Message, name string, flags uint64, vfs string)
- func EncodePrepare(request *Message, db uint64, sql string)
- func EncodePromote(request *Message, id uint64)
- func EncodeQuery(request *Message, db uint32, stmt uint32, values NamedValues)
- func EncodeQuerySQL(request *Message, db uint64, sql string, values NamedValues)
- func EncodeRemove(request *Message, id uint64)
- func TCPDial(ctx context.Context, address string) (net.Conn, error)
- func UnixDial(ctx context.Context, address string) (net.Conn, error)
- type Client
- func (c *Client) Call(ctx context.Context, request, response *Message) (err error)
- func (c *Client) Close() error
- func (c *Client) Interrupt(ctx context.Context, request *Message, response *Message) error
- func (c *Client) More(ctx context.Context, response *Message) error
- func (c *Client) SetContextTimeout(timeout time.Duration)
- type Config
- type Connector
- type ErrRequest
- type InmemServerStore
- type Message
- type NamedValues
- type Result
- type Rows
- type ServerInfo
- type ServerStore
- type Servers
Constants ¶
This section is empty.
Variables ¶
var (
ErrNoAvailableLeader = fmt.Errorf("no available dqlite leader server found")
)
Client errors.
var ErrRowsPart = fmt.Errorf("not all rows were returned in this response")
ErrRowsPart is returned when the first batch of a multi-response result batch is done.
Functions ¶
func DecodeEmpty ¶
DecodeEmpty decodes a Empty response.
func DecodeFailure ¶
DecodeFailure decodes a Failure response.
func DecodeServer ¶
DecodeServer decodes a Server response.
func DecodeStmt ¶
DecodeStmt decodes a Stmt response.
func DecodeWelcome ¶
DecodeWelcome decodes a Welcome response.
func EncodeClient ¶
EncodeClient encodes a Client request.
func EncodeExec ¶
func EncodeExec(request *Message, db uint32, stmt uint32, values NamedValues)
EncodeExec encodes a Exec request.
func EncodeExecSQL ¶
func EncodeExecSQL(request *Message, db uint64, sql string, values NamedValues)
EncodeExecSQL encodes a ExecSQL request.
func EncodeFinalize ¶
EncodeFinalize encodes a Finalize request.
func EncodeHeartbeat ¶
EncodeHeartbeat encodes a Heartbeat request.
func EncodeInterrupt ¶ added in v0.2.1
EncodeInterrupt encodes a Interrupt request.
func EncodeJoin ¶ added in v0.9.2
EncodeJoin encodes a Join request.
func EncodeOpen ¶
EncodeOpen encodes a Open request.
func EncodePrepare ¶
EncodePrepare encodes a Prepare request.
func EncodePromote ¶ added in v0.9.2
EncodePromote encodes a Promote request.
func EncodeQuery ¶
func EncodeQuery(request *Message, db uint32, stmt uint32, values NamedValues)
EncodeQuery encodes a Query request.
func EncodeQuerySQL ¶
func EncodeQuerySQL(request *Message, db uint64, sql string, values NamedValues)
EncodeQuerySQL encodes a QuerySQL request.
func EncodeRemove ¶ added in v0.9.2
EncodeRemove encodes a Remove request.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client connecting to a dqlite server and speaking the dqlite wire protocol.
func (*Client) Call ¶
Call invokes a dqlite RPC, sending a request message and receiving a response message.
func (*Client) Interrupt ¶ added in v0.2.1
Interrupt sends an interrupt request and awaits for the server's empty response.
func (*Client) SetContextTimeout ¶ added in v0.2.2
SetContextTimeout sets the default context timeout when no deadline is provided.
type Config ¶
type Config struct { Dial bindings.DialFunc // Network dialer. AttemptTimeout time.Duration // Timeout for each individual Dial attempt. RetryStrategies []strategy.Strategy // Strategies used for retrying to connect to a leader. }
Config holds various configuration parameters for a dqlite client.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector is in charge of creating a dqlite SQL client connected to the current leader of a cluster.
func NewConnector ¶
NewConnector returns a new connector that can be used by a dqlite driver to create new clients connected to a leader dqlite server.
type ErrRequest ¶
ErrRequest is returned in case of request failure.
func (ErrRequest) Error ¶
func (e ErrRequest) Error() string
type InmemServerStore ¶
type InmemServerStore struct {
// contains filtered or unexported fields
}
InmemServerStore keeps the list of servers in memory.
func NewInmemServerStore ¶
func NewInmemServerStore() *InmemServerStore
NewInmemServerStore creates ServerStore which stores its data in-memory.
func (*InmemServerStore) Get ¶
func (i *InmemServerStore) Get(ctx context.Context) ([]ServerInfo, error)
Get the current servers.
func (*InmemServerStore) Set ¶
func (i *InmemServerStore) Set(ctx context.Context, servers []ServerInfo) error
Set the servers.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message holds data about a single request or response.
type NamedValues ¶
type NamedValues = []driver.NamedValue
NamedValues is a type alias of a slice of driver.NamedValue. It's used by schema.sh to generate encoding logic for statement parameters.
type Result ¶
Result holds the result of a statement.
func DecodeResult ¶
DecodeResult decodes a Result response.
type Rows ¶
type Rows struct { Columns []string // contains filtered or unexported fields }
Rows holds a result set encoded in a message body.
func DecodeRows ¶
DecodeRows decodes a Rows response.
type ServerInfo ¶
type ServerInfo = bindings.ServerInfo
ServerInfo holds information about a single server.
type ServerStore ¶
type ServerStore interface { // Get return the list of known servers. Get(context.Context) ([]ServerInfo, error) // Set updates the list of known cluster servers. Set(context.Context, []ServerInfo) error }
ServerStore is used by a dqlite client to get an initial list of candidate dqlite servers that it can dial in order to find a leader server to connect to.
Once connected, the client periodically updates the server addresses in the store by querying the leader about changes in the cluster (such as servers being added or removed).
type Servers ¶
type Servers []bindings.ServerInfo
Servers is a type alias of a slice of bindings.ServerInfo. It's used by schema.sh to generate decoding logic for the heartbeat response.
func DecodeServers ¶
DecodeServers decodes a Servers response.