log

package
v0.0.0-...-d009716 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: MIT Imports: 22 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 raft.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

func (*DistributedLog) GetServers

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

func (*DistributedLog) Join

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

func (*DistributedLog) Leave

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

func (*DistributedLog) Read

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

func (*DistributedLog) WaitForLeader

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

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 returns a new Log instance

func (*Log) Append

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

Append adds a record to the Log

func (*Log) Close

func (l *Log) Close() error

Close will close the Log

func (*Log) HighestOffset

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

HighestOffset will return the highest offset of the Log

func (*Log) LowestOffset

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

LowestOffset will return the lowest offset of the Log

func (*Log) Read

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

Read returns the record at the given offset

func (*Log) Reader

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

Reader returns an io.Reader to read the entire Log

func (*Log) Remove

func (l *Log) Remove() error

Remove will close the Log and remove any files

func (*Log) Reset

func (l *Log) Reset() error

Reset will clear the Log

func (*Log) Truncate

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

Truncate removes all segments from the log 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)

Jump to

Keyboard shortcuts

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