bindings

package
v0.9.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Integer = C.SQLITE_INTEGER
	Float   = C.SQLITE_FLOAT
	Text    = C.SQLITE_TEXT
	Blob    = C.SQLITE_BLOB
	Null    = C.SQLITE_NULL
)

SQLite datatype codes

View Source
const (
	UnixTime = C.DQLITE_UNIXTIME
	ISO8601  = C.DQLITE_ISO8601
	Boolean  = C.DQLITE_BOOLEAN
)

Special data types for time values.

View Source
const (
	LogDebug = C.DQLITE_DEBUG
	LogInfo  = C.DQLITE_INFO
	LogWarn  = C.DQLITE_WARN
	LogError = C.DQLITE_ERROR
)

Logging levels.

View Source
const (
	Unavailable = C.DQLITE_UNAVAILABLE
	Follower    = C.DQLITE_FOLLOWER
	Candidate   = C.DQLITE_CANDIDATE
	Leader      = C.DQLITE_LEADER
)

States

View Source
const (
	RequestLeader    = C.DQLITE_REQUEST_LEADER
	RequestClient    = C.DQLITE_REQUEST_CLIENT
	RequestHeartbeat = C.DQLITE_REQUEST_HEARTBEAT
	RequestOpen      = C.DQLITE_REQUEST_OPEN
	RequestPrepare   = C.DQLITE_REQUEST_PREPARE
	RequestExec      = C.DQLITE_REQUEST_EXEC
	RequestQuery     = C.DQLITE_REQUEST_QUERY
	RequestFinalize  = C.DQLITE_REQUEST_FINALIZE
	RequestExecSQL   = C.DQLITE_REQUEST_EXEC_SQL
	RequestQuerySQL  = C.DQLITE_REQUEST_QUERY_SQL
	RequestInterrupt = C.DQLITE_REQUEST_INTERRUPT
	RequestJoin      = C.DQLITE_REQUEST_JOIN
	RequestPromote   = C.DQLITE_REQUEST_PROMOTE
	RequestRemove    = C.DQLITE_REQUEST_REMOVE
)

Request types.

View Source
const (
	ResponseFailure = C.DQLITE_RESPONSE_FAILURE
	ResponseServer  = C.DQLITE_RESPONSE_SERVER
	ResponseWelcome = C.DQLITE_RESPONSE_WELCOME
	ResponseServers = C.DQLITE_RESPONSE_SERVERS
	ResponseDb      = C.DQLITE_RESPONSE_DB
	ResponseStmt    = C.DQLITE_RESPONSE_STMT
	ResponseResult  = C.DQLITE_RESPONSE_RESULT
	ResponseRows    = C.DQLITE_RESPONSE_ROWS
	ResponseEmpty   = C.DQLITE_RESPONSE_EMPTY
)

Response types.

View Source
const (
	ErrError               = C.SQLITE_ERROR
	ErrInternal            = C.SQLITE_INTERNAL
	ErrNoMem               = C.SQLITE_NOMEM
	ErrInterrupt           = C.SQLITE_INTERRUPT
	ErrBusy                = C.SQLITE_BUSY
	ErrIoErr               = C.SQLITE_IOERR
	ErrIoErrNotLeader      = C.SQLITE_IOERR_NOT_LEADER
	ErrIoErrLeadershipLost = C.SQLITE_IOERR_LEADERSHIP_LOST
)

Error codes.

View Source
const ProtocolVersion = uint64(C.DQLITE_PROTOCOL_VERSION)

ProtocolVersion is the latest dqlite server protocol version.

Variables

View Source
var ErrServerCantBootstrap = fmt.Errorf("server already bootstrapped")

ErrServerCantBootstrap is returned by Server.Bootstrap() if the server has already a raft configuration.

View Source
var ErrServerStopped = fmt.Errorf("server was stopped")

ErrServerStopped is returned by Server.Handle() is the server was stopped.

Functions

func ErrorCode

func ErrorCode(err error) int

ErrorCode extracts a SQLite error code from a Go error.

func Init

func Init() error

Init initializes dqlite global state.

Types

type DialFunc added in v0.9.2

type DialFunc func(context.Context, string) (net.Conn, error)

DialFunc is a function that can be used to establish a network connection.

type Error

type Error struct {
	Code    int
	Message string
}

Error holds information about a SQLite error.

func (Error) Error

func (e Error) Error() string

type LogFunc added in v0.9.2

type LogFunc func(int, string)

LogFunc is a function emitting a single log message.

type Server

type Server C.dqlite

Server is a Go wrapper arround dqlite_server.

func NewServer

func NewServer(id uint, address string, dir string) (*Server, error)

NewServer creates a new Server instance.

func (*Server) Bootstrap added in v0.9.0

func (s *Server) Bootstrap(servers []ServerInfo) error

Bootstrap the a server, setting its initial raft configuration.

func (*Server) Close

func (s *Server) Close()

Close the server releasing all used resources.

func (*Server) Cluster added in v0.9.2

func (s *Server) Cluster() ([]ServerInfo, error)

Cluster returns information about all servers in the cluster.

func (*Server) Dump added in v0.9.2

func (s *Server) Dump(filename string) ([]byte, error)

Dump a database file.

func (*Server) Handle

func (s *Server) Handle(conn net.Conn) error

Handle a new connection.

func (*Server) Leader added in v0.9.2

func (s *Server) Leader() *ServerInfo

Leader returns information about the current leader, if any.

func (*Server) Ready

func (s *Server) Ready() bool

Ready waits for the server to be ready to handle connections.

func (*Server) Run

func (s *Server) Run() error

Run the server.

func (*Server) SetDialFunc added in v0.9.2

func (s *Server) SetDialFunc(dial DialFunc)

SetDialFunc configure a custom dial function.

func (*Server) SetLogFunc added in v0.9.2

func (s *Server) SetLogFunc(log LogFunc)

SetLogFunc configure a custom log function.

func (*Server) SetWatchFunc added in v0.9.3

func (s *Server) SetWatchFunc(watch WatchFunc)

SetWatchFunc configures a watch function to be notified about state changes.

func (*Server) Stop

func (s *Server) Stop() error

Stop the server.

type ServerInfo

type ServerInfo struct {
	ID      uint64
	Address string
}

ServerInfo is the Go equivalent of dqlite_server.

type WatchFunc added in v0.9.3

type WatchFunc func(int, int)

WatchFunc is a function notifiying about state changes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL