raft

package
v0.0.0-...-62b3d66 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2017 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDebug

func SetDebug(w io.Writer)

Types

type Command

type Command struct {
	Op    Op     `json:"op,omitempty"`
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

type Config

type Config struct {
	Debug bool

	Dir string

	Addr string

	RetainSnapshotCount int

	EnableSingle bool

	RaftTimeout time.Duration

	StreamLayer raft.StreamLayer

	InitialPeers []string

	Logger *jolt.Logger
}

type Op

type Op int
const (
	Get Op = iota
	Set
	Delete
)

type Raft

type Raft struct {
	*raft.Raft

	RPC *RaftRPC
	// contains filtered or unexported fields
}

func NewRaft

func NewRaft(c *Config) (r *Raft, err error)

func (*Raft) Barrier

func (r *Raft) Barrier() error

func (*Raft) Config

func (r *Raft) Config() raft.Configuration

func (*Raft) Delete

func (r *Raft) Delete(key string) error

func (*Raft) Get

func (r *Raft) Get(key string) (string, error)

func (*Raft) IsLeader

func (r *Raft) IsLeader() bool

func (*Raft) Join

func (r *Raft) Join(id, addr string) error

func (*Raft) LocalID

func (r *Raft) LocalID() string

func (*Raft) Set

func (r *Raft) Set(key, value string) error

type RaftLayer

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

func NewRaftLayer

func NewRaftLayer(addr net.Addr) *RaftLayer

func (*RaftLayer) Accept

func (l *RaftLayer) Accept() (net.Conn, error)

func (*RaftLayer) Addr

func (l *RaftLayer) Addr() net.Addr

func (*RaftLayer) Close

func (l *RaftLayer) Close() error

func (*RaftLayer) Dial

func (l *RaftLayer) Dial(address raft.ServerAddress, timeout time.Duration) (net.Conn, error)

func (*RaftLayer) Handoff

func (l *RaftLayer) Handoff(c net.Conn) error

func (*RaftLayer) Type

func (l *RaftLayer) Type() rpc.RPCType

type RaftRPC

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

func (*RaftRPC) Delete

func (r *RaftRPC) Delete(c *Command, resp *string) error

func (*RaftRPC) Get

func (r *RaftRPC) Get(c *Command, resp *string) error

func (*RaftRPC) Set

func (r *RaftRPC) Set(c *Command, resp *string) error

type Store

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

func (*Store) Apply

func (s *Store) Apply(l *raft.Log) interface{}

func (*Store) Delete

func (s *Store) Delete(key string)

func (*Store) Get

func (s *Store) Get(key string) (string, bool)

func (*Store) Restore

func (s *Store) Restore(rc io.ReadCloser) error

func (*Store) Set

func (s *Store) Set(key, value string)

func (*Store) Snapshot

func (s *Store) Snapshot() (raft.FSMSnapshot, error)

Jump to

Keyboard shortcuts

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