core

package
v0.0.0-...-e115005 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TIMEOUT = 10 * time.Second

Variables

This section is empty.

Functions

func GetLogger

func GetLogger(name ...string) *log.Entry

func InitLogger

func InitLogger()

Types

type CommonResponse

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

type Config

type Config struct {
	SingleNode *bool  `json:"singleNode"`
	HttpAddr   string `json:"httpAddr"`
	RaftAddr   string `json:"raftAddr"`
	JoinAddr   string `json:"joinAddr"`
	ID         string `json:"id"`
	RaftPath   string `json:"raftPath"`
}

func InitConfig

func InitConfig() (*Config, error)

type IOperation

type IOperation interface {
	// contains filtered or unexported methods
}

type IStore

type IStore interface {
	raft.FSM
	ApplyPut(key string, value string) interface{}
	ApplyDelete(key string) interface{}
}

type JoinRequestBody

type JoinRequestBody struct {
	ID   string `json:"id"`
	Addr string `json:"addr"`
}

type Operation

type Operation struct {
	Name  string `json:"name"`
	Key   string `json:"key"`
	Value string `json:"value"`
}

type Server

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

func CreateServer

func CreateServer(c *Config) (*Server, error)

func (*Server) Run

func (s *Server) Run()

type Snapshot

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

func (*Snapshot) Persist

func (s *Snapshot) Persist(sink raft.SnapshotSink) error

func (*Snapshot) Release

func (s *Snapshot) Release()

type Store

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

Store implements raft.FSM

func NewStore

func NewStore(singleNode bool, id string, raftAddr string, raftPath string, joinAddr string) (*Store, error)

func (*Store) Apply

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

implements raft.FSM

func (*Store) ApplyDelete

func (s *Store) ApplyDelete(key string) interface{}

func (*Store) ApplyPut

func (s *Store) ApplyPut(key string, value string) interface{}

implements IStore

func (*Store) Delete

func (s *Store) Delete(key string) error

func (*Store) Get

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

func (*Store) Join

func (s *Store) Join(id string, addr string) error

func (*Store) Put

func (s *Store) Put(key string, value string) error

func (*Store) Restore

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

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