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 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 EncodeLeader(request *Message)
- func EncodeOpen(request *Message, name string, flags uint64, vfs string)
- func EncodePrepare(request *Message, db uint64, sql string)
- 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 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 Message
- type NamedValues
- type NodeInfo
- type NodeRole
- type NodeStore
- type Nodes
- type Protocol
- 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 (
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.
var TLSCipherSuites = []uint16{ tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, }
TLSCipherSuites are the cipher suites by the go-dqlite TLS helpers.
Functions ¶
func DecodeEmpty ¶
DecodeEmpty decodes a Empty response.
func DecodeFailure ¶
DecodeFailure decodes a Failure response.
func DecodeMetadata ¶
DecodeMetadata decodes a Metadata response.
func DecodeNode ¶
DecodeNode decodes a Node response.
func DecodeNodeCompat ¶
DecodeNodeCompat handles also pre-1.0 legacy server messages.
func DecodeNodeLegacy ¶
DecodeNodeLegacy decodes a NodeLegacy response.
func DecodeStmt ¶
DecodeStmt decodes a Stmt response.
func DecodeWelcome ¶
DecodeWelcome decodes a Welcome response.
func EncodeAssign ¶
EncodeAssign encodes a Assign request.
func EncodeClient ¶
EncodeClient encodes a Client request.
func EncodeCluster ¶
EncodeCluster encodes a Cluster request.
func EncodeDescribe ¶
EncodeDescribe encodes a Describe 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 ¶
EncodeInterrupt encodes a Interrupt request.
func EncodeOpen ¶
EncodeOpen encodes a Open request.
func EncodePrepare ¶
EncodePrepare encodes a Prepare 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 ¶
EncodeRemove encodes a Remove request.
func EncodeTransfer ¶
EncodeTransfer encodes a Transfer request.
func EncodeWeight ¶
EncodeWeight encodes a Weight request.
Types ¶
type Config ¶
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. }
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 Files ¶
type Files struct {
// contains filtered or unexported fields
}
Files holds a set of files encoded in a message body.
func DecodeFiles ¶
DecodeFiles decodes a Files response.
type InmemNodeStore ¶
type InmemNodeStore struct {
// contains filtered or unexported fields
}
InmemNodeStore keeps the list of servers in memory.
func NewInmemNodeStore ¶
func NewInmemNodeStore() *InmemNodeStore
NewInmemNodeStore creates NodeStore which stores its data in-memory.
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 NodeStore ¶
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 ¶
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 ¶
DecodeNodes decodes a Nodes response.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol sends and receive the dqlite message on the wire.
func (*Protocol) Call ¶
Call invokes a dqlite RPC, sending a request message and receiving a response message.
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.
func (*Rows) ColumnTypes ¶
ColumnTypes returns the column types for the the result set.