log

package
v0.0.0-...-11329f7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const RaftRPC = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Raft struct {
		raft.Config
		BindAddr    string
		StreamLayer *StreamLayer
		Bootstrap   bool
	}
	Segment struct {
		MaxStoreBytes uint64
		MaxIndexBytes uint64
		InitialOffset uint64
	}
}

type DistributedLog

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

func NewDistributedLog

func NewDistributedLog(dataDir string, config Config) (*DistributedLog, error)

func (*DistributedLog) Append

func (l *DistributedLog) Append(record *api.Record) (uint64, error)

func (*DistributedLog) Close

func (l *DistributedLog) Close() error

Close shuts down the Raft instance and closes the local log.

func (*DistributedLog) GetServers

func (l *DistributedLog) GetServers() ([]*api.Server, error)

func (*DistributedLog) Join

func (l *DistributedLog) Join(id, addr string) error

Join adds the server to the Raft cluster.

func (*DistributedLog) Leave

func (l *DistributedLog) Leave(id string) error

Leave removes the server from the cluster. Removing the leader will trigger a new election.

func (*DistributedLog) Read

func (l *DistributedLog) Read(offset uint64) (*api.Record, error)

func (*DistributedLog) WaitForLeader

func (l *DistributedLog) WaitForLeader(timeout time.Duration) error

WaitForLeader blocks until a leader is elected or times out.

type Log

type Log struct {
	Dir    string
	Config Config
	// contains filtered or unexported fields
}

func NewLog

func NewLog(dir string, c Config) (*Log, error)

NewLog creates a log instance.

func (*Log) Append

func (l *Log) Append(record *api.Record) (uint64, error)

Append appends a record to the log.

func (*Log) Close

func (l *Log) Close() error

Close iterates over the segments and closes them.

func (*Log) HighestOffset

func (l *Log) HighestOffset() (uint64, error)

HighestOffset returns the highest offset stored in the log.

func (*Log) LowestOffset

func (l *Log) LowestOffset() (uint64, error)

LowestOffset returns the lowest offset stored in the log.

func (*Log) Read

func (l *Log) Read(off uint64) (*api.Record, error)

Read reads the record stored at the given offset.

func (*Log) Reader

func (l *Log) Reader() io.Reader

Reader returns an io.Reader to read the whole log.

func (*Log) Remove

func (l *Log) Remove() error

Remove closes the log and then removes its data.

func (*Log) Reset

func (l *Log) Reset() error

Reset removes the log and then creates a new log to replace it.

func (*Log) Truncate

func (l *Log) Truncate(lowest uint64) error

Truncate removes all segments whose highest offset is lower than lowest.

type RequestType

type RequestType uint8
const (
	AppendRequestType RequestType = 0
)

type StreamLayer

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

func NewStreamLayer

func NewStreamLayer(ln net.Listener, serverTLSConfig, peerTLSConfig *tls.Config) *StreamLayer

func (*StreamLayer) Accept

func (s *StreamLayer) Accept() (net.Conn, error)

func (*StreamLayer) Addr

func (s *StreamLayer) Addr() net.Addr

func (*StreamLayer) Close

func (s *StreamLayer) Close() error

func (*StreamLayer) Dial

func (s *StreamLayer) Dial(addr raft.ServerAddress, timeout time.Duration) (net.Conn, error)

Dial makes outgoing connections to other services in the Raft cluster.

Jump to

Keyboard shortcuts

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