Documentation ¶
Index ¶
- Constants
- 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 DecodeMetadata(response *Message) (failureDomain uint64, weight uint64, err error)
- func DecodeNode(response *Message) (id uint64, address string, err error)
- func DecodeNodeCompat(protocol *Protocol, response *Message) (uint64, string, error)
- func DecodeNodeLegacy(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 Dial(ctx context.Context, address string) (net.Conn, error)
- func EncodeAdd(request *Message, id uint64, address string)
- func EncodeAssign(request *Message, id uint64, role uint64)
- func EncodeClient(request *Message, id uint64)
- func EncodeCluster(request *Message, format uint64)
- func EncodeDescribe(request *Message, format uint64)
- func EncodeDump(request *Message, name string)
- func EncodeExecSQLV0(request *Message, db uint64, sql string, values NamedValues)
- func EncodeExecSQLV1(request *Message, db uint64, sql string, values NamedValues32)
- func EncodeExecV0(request *Message, db uint32, stmt uint32, values NamedValues)
- func EncodeExecV1(request *Message, db uint32, stmt uint32, values NamedValues32)
- func EncodeFinalize(request *Message, db uint32, stmt uint32)
- func EncodeHeartbeat(request *Message, timestamp uint64)
- func EncodeInterrupt(request *Message, db uint64)
- func EncodeLeader(request *Message)
- func EncodeOpen(request *Message, name string, flags uint64, vfs string)
- func EncodePrepare(request *Message, db uint64, sql string)
- func EncodeQuerySQLV0(request *Message, db uint64, sql string, values NamedValues)
- func EncodeQuerySQLV1(request *Message, db uint64, sql string, values NamedValues32)
- func EncodeQueryV0(request *Message, db uint32, stmt uint32, values NamedValues)
- func EncodeQueryV1(request *Message, db uint32, stmt uint32, values NamedValues32)
- func EncodeRemove(request *Message, id uint64)
- func EncodeTransfer(request *Message, id uint64)
- func EncodeWeight(request *Message, weight uint64)
- type Config
- type Connector
- type DialFunc
- type ErrRequest
- type Error
- type Files
- type InmemNodeStore
- type LeaderTracker
- type Message
- type NamedValues
- type NamedValues32
- type NodeInfo
- type NodeRole
- type NodeStore
- type Nodes
- type Protocol
- func (p *Protocol) Bad()
- func (p *Protocol) Call(ctx context.Context, request, response *Message) (err error)
- func (p *Protocol) Close() error
- func (p *Protocol) Interrupt(ctx context.Context, request *Message, response *Message) (err error)
- func (p *Protocol) More(ctx context.Context, response *Message) (err error)
- type Result
- type Rows
Constants ¶
const ( ClusterFormatV0 = 0 ClusterFormatV1 = 1 )
Cluster response formats
const ( Voter = NodeRole(0) StandBy = NodeRole(1) Spare = NodeRole(2) )
Node roles
const ( Integer = 1 Float = 2 Text = 3 Blob = 4 Null = 5 )
SQLite datatype codes
const ( UnixTime = 9 ISO8601 = 10 Boolean = 11 )
Special data types for time values.
const ( RequestLeader = 0 RequestClient = 1 RequestHeartbeat = 2 RequestOpen = 3 RequestPrepare = 4 RequestExec = 5 RequestQuery = 6 RequestFinalize = 7 RequestExecSQL = 8 RequestQuerySQL = 9 RequestInterrupt = 10 RequestAdd = 12 RequestAssign = 13 RequestRemove = 14 RequestDump = 15 RequestCluster = 16 RequestTransfer = 17 RequestDescribe = 18 RequestWeight = 19 )
Request types.
const ( ResponseFailure = 0 ResponseNode = 1 ResponseNodeLegacy = 1 ResponseWelcome = 2 ResponseNodes = 3 ResponseDb = 4 ResponseStmt = 5 ResponseResult = 6 ResponseRows = 7 ResponseEmpty = 8 ResponseFiles = 9 ResponseMetadata = 10 )
Response types.
const MaxConcurrentLeaderConns int64 = 10
MaxConcurrentLeaderConns is the default maximum number of concurrent requests to other cluster members to probe for leadership.
const (
RequestDescribeFormatV0 = 0
)
Formats
const VersionLegacy = uint64(0x86104dd760433fe5)
VersionLegacy is the pre 1.0 dqlite server protocol version.
const VersionOne = uint64(1)
VersionOne is version 1 of the server protocol.
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 ¶ added in v1.0.0
DecodeEmpty decodes a Empty response.
func DecodeFailure ¶ added in v1.0.0
DecodeFailure decodes a Failure response.
func DecodeMetadata ¶ added in v1.7.0
DecodeMetadata decodes a Metadata response.
func DecodeNode ¶ added in v1.0.0
DecodeNode decodes a Node response.
func DecodeNodeCompat ¶ added in v1.0.0
DecodeNodeCompat handles also pre-1.0 legacy server messages.
func DecodeNodeLegacy ¶ added in v1.0.0
DecodeNodeLegacy decodes a NodeLegacy response.
func DecodeStmt ¶ added in v1.0.0
DecodeStmt decodes a Stmt response.
func DecodeWelcome ¶ added in v1.0.0
DecodeWelcome decodes a Welcome response.
func EncodeAssign ¶ added in v1.3.0
EncodeAssign encodes a Assign request.
func EncodeClient ¶ added in v1.0.0
EncodeClient encodes a Client request.
func EncodeCluster ¶ added in v1.0.0
EncodeCluster encodes a Cluster request.
func EncodeDescribe ¶ added in v1.7.0
EncodeDescribe encodes a Describe request.
func EncodeDump ¶ added in v1.0.0
EncodeDump encodes a Dump request.
func EncodeExecSQLV0 ¶ added in v1.20.0
func EncodeExecSQLV0(request *Message, db uint64, sql string, values NamedValues)
EncodeExecSQLV0 encodes a ExecSQL request.
func EncodeExecSQLV1 ¶ added in v1.20.0
func EncodeExecSQLV1(request *Message, db uint64, sql string, values NamedValues32)
EncodeExecSQLV1 encodes a ExecSQL request.
func EncodeExecV0 ¶ added in v1.20.0
func EncodeExecV0(request *Message, db uint32, stmt uint32, values NamedValues)
EncodeExecV0 encodes a Exec request.
func EncodeExecV1 ¶ added in v1.20.0
func EncodeExecV1(request *Message, db uint32, stmt uint32, values NamedValues32)
EncodeExecV1 encodes a Exec request.
func EncodeFinalize ¶ added in v1.0.0
EncodeFinalize encodes a Finalize request.
func EncodeHeartbeat ¶ added in v1.0.0
EncodeHeartbeat encodes a Heartbeat request.
func EncodeInterrupt ¶ added in v1.0.0
EncodeInterrupt encodes a Interrupt request.
func EncodeLeader ¶ added in v1.0.0
func EncodeLeader(request *Message)
EncodeLeader encodes a Leader request.
func EncodeOpen ¶ added in v1.0.0
EncodeOpen encodes a Open request.
func EncodePrepare ¶ added in v1.0.0
EncodePrepare encodes a Prepare request.
func EncodeQuerySQLV0 ¶ added in v1.20.0
func EncodeQuerySQLV0(request *Message, db uint64, sql string, values NamedValues)
EncodeQuerySQLV0 encodes a QuerySQL request.
func EncodeQuerySQLV1 ¶ added in v1.20.0
func EncodeQuerySQLV1(request *Message, db uint64, sql string, values NamedValues32)
EncodeQuerySQLV1 encodes a QuerySQL request.
func EncodeQueryV0 ¶ added in v1.20.0
func EncodeQueryV0(request *Message, db uint32, stmt uint32, values NamedValues)
EncodeQueryV0 encodes a Query request.
func EncodeQueryV1 ¶ added in v1.20.0
func EncodeQueryV1(request *Message, db uint32, stmt uint32, values NamedValues32)
EncodeQueryV1 encodes a Query request.
func EncodeRemove ¶ added in v1.0.0
EncodeRemove encodes a Remove request.
func EncodeTransfer ¶ added in v1.3.0
EncodeTransfer encodes a Transfer request.
func EncodeWeight ¶ added in v1.7.0
EncodeWeight encodes a Weight request.
Types ¶
type Config ¶ added in v1.0.0
type Config struct { Dial DialFunc // Network dialer. DialTimeout time.Duration // Timeout for establishing a network connection . AttemptTimeout time.Duration // Timeout for each individual attempt to probe a server's leadership. BackoffFactor time.Duration // Exponential backoff factor for retries. BackoffCap time.Duration // Maximum connection retry backoff value, RetryLimit uint // Maximum number of retries, or 0 for unlimited. ConcurrentLeaderConns int64 // Maximum number of concurrent connections to other cluster members while probing for leadership. }
Config holds various configuration parameters for a dqlite client.
func (Config) RetryStrategies ¶ added in v1.0.0
RetryStrategies returns a configuration for the retry package based on a Config.
type Connector ¶ added in v1.0.0
type Connector struct {
// contains filtered or unexported fields
}
func NewDirectConnector ¶ added in v1.99.99
NewDirectConnector returns a Connector that will connect to the node with the given ID and address.
func NewLeaderConnector ¶ added in v1.99.99
NewConnector returns a Connector that will connect to the current cluster leader.
type DialFunc ¶ added in v1.0.0
DialFunc is a function that can be used to establish a network connection.
type ErrRequest ¶ added in v1.0.0
ErrRequest is returned in case of request failure.
func (ErrRequest) Error ¶ added in v1.0.0
func (e ErrRequest) Error() string
type Files ¶ added in v1.0.0
type Files struct {
// contains filtered or unexported fields
}
Files holds a set of files encoded in a message body.
func DecodeFiles ¶ added in v1.0.0
DecodeFiles decodes a Files response.
type InmemNodeStore ¶ added in v1.0.0
type InmemNodeStore struct {
// contains filtered or unexported fields
}
InmemNodeStore keeps the list of servers in memory.
func NewInmemNodeStore ¶ added in v1.0.0
func NewInmemNodeStore() *InmemNodeStore
NewInmemNodeStore creates NodeStore which stores its data in-memory.
type LeaderTracker ¶ added in v1.99.99
type LeaderTracker struct {
// contains filtered or unexported fields
}
LeaderTracker remembers the address of the cluster leader, and possibly holds a reusable connection to it.
func (*LeaderTracker) DonateSharedProtocol ¶ added in v1.99.99
func (lt *LeaderTracker) DonateSharedProtocol(proto *Protocol) (accepted bool)
func (*LeaderTracker) GetLeaderAddr ¶ added in v1.99.99
func (lt *LeaderTracker) GetLeaderAddr() string
func (*LeaderTracker) SetLeaderAddr ¶ added in v1.99.99
func (lt *LeaderTracker) SetLeaderAddr(address string)
func (*LeaderTracker) TakeSharedProtocol ¶ added in v1.99.99
func (lt *LeaderTracker) TakeSharedProtocol() (proto *Protocol)
func (*LeaderTracker) UnsetLeaderAddr ¶ added in v1.99.99
func (lt *LeaderTracker) UnsetLeaderAddr()
type Message ¶ added in v1.0.0
type Message struct {
// contains filtered or unexported fields
}
Message holds data about a single request or response.
type NamedValues ¶ added in v1.0.0
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 NamedValues32 ¶ added in v1.20.0
type NamedValues32 = []driver.NamedValue
type NodeInfo ¶ added in v1.0.0
type NodeInfo struct { ID uint64 `yaml:"ID"` Address string `yaml:"Address"` Role NodeRole `yaml:"Role"` }
NodeInfo holds information about a single server.
type NodeStore ¶ added in v1.0.0
type NodeStore interface { // Get return the list of known servers. Get(context.Context) ([]NodeInfo, error) // Set updates the list of known cluster servers. Set(context.Context, []NodeInfo) error }
NodeStore 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 Nodes ¶ added in v1.0.0
type Nodes []NodeInfo
Nodes is a type alias of a slice of NodeInfo. It's used by schema.sh to generate decoding logic for the heartbeat response.
func DecodeNodes ¶ added in v1.0.0
DecodeNodes decodes a Nodes response.
type Protocol ¶ added in v1.0.0
type Protocol struct {
// contains filtered or unexported fields
}
Protocol sends and receive the dqlite message on the wire.
func (*Protocol) Bad ¶ added in v1.99.99
func (p *Protocol) Bad()
Bad prevents a protocol from being reused when it is released.
There is no need to call Bad after a method of Protocol returns an error. Only call Bad when the protocol is deemed unsuitable for reuse for some higher-level reason.
func (*Protocol) Call ¶ added in v1.0.0
Call invokes a dqlite RPC, sending a request message and receiving a response message.
func (*Protocol) Close ¶ added in v1.0.0
Close releases a protocol.
If the protocol was associated with a LeaderTracker, it will be made available for reuse by that tracker. Otherwise, the underlying connection will be closed.
type Result ¶ added in v1.0.0
Result holds the result of a statement.
func DecodeResult ¶ added in v1.0.0
DecodeResult decodes a Result response.
type Rows ¶ added in v1.0.0
type Rows struct { Columns []string // contains filtered or unexported fields }
Rows holds a result set encoded in a message body.
func DecodeRows ¶ added in v1.0.0
DecodeRows decodes a Rows response.
func (*Rows) ColumnTypes ¶ added in v1.2.0
ColumnTypes returns the column types for the the result set.