types

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package types defines required types of kayak.

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

Types

type ApplyRequest

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

ApplyRequest defines the apply request entity.

type FetchRequest

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

FetchRequest defines the fetch request entity.

type FetchResponse

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

FetchResponse defines the fetch response entity.

type Handler

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

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

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

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

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

type RuntimeConfig

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

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.

Jump to

Keyboard shortcuts

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