CovenantSQL: github.com/CovenantSQL/CovenantSQL/kayak/types Index | Files

package types

import "github.com/CovenantSQL/CovenantSQL/kayak/types"

Package types defines required types of kayak.

Index

Package Files

config.go doc.go errors.go handler.go log.go rpc.go wal.go

Variables

var (
    // ErrNotLeader represents current node is not a peer leader.
    ErrNotLeader = errors.New("not leader")
    // ErrNotFollower represents current node is not a peer follower.
    ErrNotFollower = errors.New("not follower")
    // ErrPrepareTimeout represents timeout failure for prepare operation.
    ErrPrepareTimeout = errors.New("prepare timeout")
    // ErrPrepareFailed represents failure for prepare operation.
    ErrPrepareFailed = errors.New("prepare failed")
    // ErrInvalidLog represents log is invalid.
    ErrInvalidLog = errors.New("invalid log")
    // ErrNotInPeer represents current node does not exists in peer list.
    ErrNotInPeer = errors.New("node not in peer")
    // ErrInvalidConfig represents invalid kayak runtime config.
    ErrInvalidConfig = errors.New("invalid runtime config")
    // ErrStopped represents runtime not started.
    ErrStopped = errors.New("stopped")
)

type ApplyRequest Uses

type ApplyRequest struct {
    proto.Envelope
    Instance string
    Log      *Log
}

ApplyRequest defines the apply request entity.

type FetchRequest Uses

type FetchRequest struct {
    proto.Envelope
    Instance string
    Index    uint64
}

FetchRequest defines the fetch request entity.

type FetchResponse Uses

type FetchResponse struct {
    proto.Envelope
    Instance string
    Log      *Log
}

FetchResponse defines the fetch response entity.

type Handler Uses

type Handler interface {
    EncodePayload(req interface{}) (data []byte, err error)
    DecodePayload(data []byte) (req interface{}, err error)
    Check(request interface{}) error
    Commit(request interface{}, isLeader bool) (result interface{}, err error)
}

Handler defines the main underlying fsm of kayak.

type Log Uses

type Log struct {
    LogHeader
    // Data could be detected and handle decode properly by log layer
    Data []byte
}

Log defines the log data structure.

type LogHeader Uses

type LogHeader struct {
    Index      uint64       // log index
    Version    uint64       // log version
    Type       LogType      // log type
    Producer   proto.NodeID // producer node
    DataLength uint64       // data length
}

LogHeader defines the checksum header structure.

type LogType Uses

type LogType uint16

LogType defines the log type.

const (
    // LogPrepare defines the prepare phase of a commit.
    LogPrepare LogType = iota
    // LogRollback defines the rollback phase of a commit.
    LogRollback
    // LogCommit defines the commit phase of a commit.
    LogCommit
    // LogCheckpoint defines the checkpoint log (created/virtually created by block production or log truncation).
    LogCheckpoint
    // LogBarrier defines barrier log, all open windows should be waiting this operations to complete.
    LogBarrier
    // LogNoop defines noop log.
    LogNoop
)

func (LogType) String Uses

func (t LogType) String() (s string)

type RuntimeConfig Uses

type RuntimeConfig struct {
    // underlying handler.
    Handler Handler
    // minimum rpc success node percent requirement for prepare operation.
    PrepareThreshold float64
    // minimum rpc success node percent requirement for commit operation.
    CommitThreshold float64
    // maximum allowed time for prepare operation.
    PrepareTimeout time.Duration
    // maximum allowed time for commit operation.
    CommitTimeout time.Duration
    // init peers of node.
    Peers *proto.Peers
    // wal for kayak.
    Wal Wal
    // current node id.
    NodeID proto.NodeID
    // current instance id.
    InstanceID string
    // mux service name.
    ServiceName string
    // apply service method.
    ApplyMethodName string
    // fetch service method.
    FetchMethodName string
    // fetch timeout.
    LogWaitTimeout time.Duration
}

RuntimeConfig defines the runtime config of kayak.

type Wal Uses

type Wal interface {
    // sequential write
    Write(*Log) error
    // sequential read, return io.EOF if there is no more records to read
    Read() (*Log, error)
    // random access
    Get(index uint64) (*Log, error)
}

Wal defines the log storage interface.

Package types imports 3 packages (graph) and is imported by 6 packages. Updated 2019-02-28. Refresh now. Tools for package owners.