server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package server implements a server to handle grpc requests to the storage engine and raft engine.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotReady       error = errors.New("Serve not ready")
	ErrCanceled       error = errors.New("Request canceled by client")
	ErrInternal       error = errors.New("Internal server error (please see server's logs for more details)")
	ErrLeaderNotFound error = errors.New("Leader not found (please try again)")
)

Errors returned by grpc servers.

Functions

This section is empty.

Types

type Server

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

Server serves grpc requests coming from storage and raft clients.

func New

func New(level int, rootdir string, flushThresh store.KVLen, blockSize store.KVLen) (*Server, error)

New creates a Server with given logging level and storage engine configurations.

func (*Server) AppendEntries

func (s *Server) AppendEntries(ctx context.Context, req *pb.AppendEntriesReq) (*pb.AppendEntriesResp, error)

AppendEntries invoked by raft leader to replicate log entries, also used as heartbeat.

func (*Server) Del

func (s *Server) Del(ctx context.Context, req *pb.DelReq) (*pb.DelResp, error)

Del removes a key-value pair.

func (*Server) Get

func (s *Server) Get(ctx context.Context, req *pb.GetReq) (*pb.GetResp, error)

Get returns the value associated with given key.

func (*Server) Put

func (s *Server) Put(ctx context.Context, req *pb.PutReq) (*pb.PutResp, error)

Put adds or updates a key-value pair.

func (*Server) RequestVote

func (s *Server) RequestVote(ctx context.Context, req *pb.RequestVoteReq) (*pb.RequestVoteResp, error)

RequestVote invoked by raft candidates to gather votes.

func (*Server) Serve

func (s *Server) Serve(storageAddr string, raftAddr string) error

Serve starts a storage grpc server (listening to storageAddr) and a raft grpc server (listening to raftAddr) to handle incoming requests.

Jump to

Keyboard shortcuts

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