server

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TWO_PHASE   = "two-phase"
	THREE_PHASE = "three-phase"
)

Variables

This section is empty.

Functions

func PrecommitBlockALL

func PrecommitBlockALL(ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

PrecommitBlock blocks execution of all followers on precommit stage for 10s

func PrecommitBlockCoordinator

func PrecommitBlockCoordinator(ctx context.Context,
	req interface{},
	_ *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

PrecommitBlockCoordinator blocks execution of coordinator on precommit stage for 1s

func PrecommitOneFollowerFail

func PrecommitOneFollowerFail(ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

func WhiteListChecker

func WhiteListChecker(ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler) (interface{}, error)

WhiteListChecker intercepts RPC and checks that the caller is whitelisted.

func WithBadgerDB

func WithBadgerDB(path string) func(*Server) error

WithBadgerDB adds BadgerDB manager to the Server instance

Types

type Coordinator

type Coordinator interface {
	Broadcast(ctx context.Context, req entity.BroadcastRequest) (*entity.BroadcastResponse, error)
	Height() uint64
}

type Option

type Option func(server *Server) error

type Server

type Server struct {
	proto.UnimplementedCommitServer
	Addr        string
	GRPCServer  *grpc.Server
	DB          db.Repository
	DBPath      string
	ProposeHook func(req *proto.ProposeRequest) bool
	CommitHook  func(req *proto.CommitRequest) bool
	Tracer      *zipkin.Tracer
	Config      *config.Config
	// contains filtered or unexported fields
}

Server holds server instance, node config and connections to followers (if it's a coordinator node)

func New

func New(conf *config.Config, tracer *zipkin.Tracer, cohort cohort.Cohort, coordinator Coordinator, database db.Repository, opts ...Option) (*Server, error)

New fabric func for Server

func (*Server) Commit

func (s *Server) Commit(ctx context.Context, req *proto.CommitRequest) (*proto.Response, error)

func (*Server) Get

func (s *Server) Get(ctx context.Context, req *proto.Msg) (*proto.Value, error)

func (*Server) NodeInfo

func (s *Server) NodeInfo(ctx context.Context, req *empty.Empty) (*proto.Info, error)

func (*Server) Precommit

func (s *Server) Precommit(ctx context.Context, req *proto.PrecommitRequest) (*proto.Response, error)

func (*Server) Propose

func (s *Server) Propose(ctx context.Context, req *proto.ProposeRequest) (*proto.Response, error)

func (*Server) Put

func (s *Server) Put(ctx context.Context, req *proto.Entry) (*proto.Response, error)

func (*Server) Run

func (s *Server) Run(opts ...grpc.UnaryServerInterceptor)

Run starts non-blocking GRPC server

func (*Server) Stop

func (s *Server) Stop()

Stop stops server

Jump to

Keyboard shortcuts

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