oracle

package
v0.0.0-...-d504ea7 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RaftConfig

type RaftConfig struct {
	// RaftHostPort is the host:port of raft HTTP server
	RaftHostPort *kronospb.NodeAddr
	// GRPCHostPort is the host:port of raft HTTP server
	GRPCHostPort *kronospb.NodeAddr
	// SeedHosts is a comma separated list of kronos seed hosts in the cluster
	SeedHosts []string
	// CertsDir is the directory having node and CA certificates / pems
	CertsDir string
	// DataDir is the directory where a Kronos server will store its snapshots
	// and raft WAL
	DataDir string
	// SnapCount is the number of raft entries after which a raft snapshot is
	// triggered.
	SnapCount uint64
}

RaftConfig is used to initialize a raft based on the given parameters

type RaftStateMachine

type RaftStateMachine struct {
	// contains filtered or unexported fields
}

RaftStateMachine is a distributed state machine managed by raft. Each node maintains an in memory state machine where the actions fed in are the actions (messages) committed through raft

func (*RaftStateMachine) Close

func (s *RaftStateMachine) Close()

Close cleans up RaftStateMachine

func (*RaftStateMachine) GetSnapshot

func (s *RaftStateMachine) GetSnapshot(ctx context.Context) ([]byte, error)

GetSnapshot returns a snapshot of the in memory state machine

func (*RaftStateMachine) State

func (s *RaftStateMachine) State(ctx context.Context) *kronospb.OracleState

State returns a snapshot of the current state of the state machine

func (*RaftStateMachine) SubmitProposal

func (s *RaftStateMachine) SubmitProposal(ctx context.Context, proposal *kronospb.OracleProposal)

SubmitProposal submits a new proposal to the StateMachine. The state machine accepts the proposal if PrevID matches the ID of the StateMachine. This function does not return anything as the proposal is async.

type StateMachine

type StateMachine interface {
	// State returns a snapshot of the current state of the state machine.
	State(ctx context.Context) *kronospb.OracleState
	// SubmitProposal submits a proposal to update the StateMachine.
	// This function does not return anything as the proposal is async, it may get
	// applied at some point in the future, or it may get rejected as well.
	SubmitProposal(ctx context.Context, proposal *kronospb.OracleProposal)
	// Close performs any necessary cleanups.
	Close()
}

StateMachine is used for managing current oracle and time cap

func NewMemStateMachine

func NewMemStateMachine() StateMachine

NewMemStateMachine returns an instance of in memory oracle state machine

func NewRaftStateMachine

func NewRaftStateMachine(ctx context.Context, rc *RaftConfig) StateMachine

NewRaftStateMachine returns an instance of a distributed oracle state machine managed by raft

Jump to

Keyboard shortcuts

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