prophet

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 30 Imported by: 2

README

prophet

Embedded distributed coordinator

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrClosed error of client closed
	ErrClosed = errors.New("client is closed")
	// ErrTimeout timeout
	ErrTimeout = errors.New("rpc timeout")
)

Functions

func StartMonitor

func StartMonitor(ctx context.Context, now func() time.Time, systimeErrHandler func())

StartMonitor calls systimeErrHandler if system time jump backward.

Types

type Client

type Client interface {
	Close() error
	AllocID() (uint64, error)
	GetContainer(containerID uint64) (metadata.Container, error)
	ResourceHeartbeat(meta metadata.Resource, hb rpcpb.ResourceHeartbeatReq) error
	ContainerHeartbeat(hb rpcpb.ContainerHeartbeatReq) (rpcpb.ContainerHeartbeatRsp, error)
	AskSplit(res metadata.Resource) (rpcpb.SplitID, error)
	ReportSplit(left, right metadata.Resource) error
	AskBatchSplit(res metadata.Resource, count uint32) ([]rpcpb.SplitID, error)
	ReportBatchSplit(results ...metadata.Resource) error
	NewWatcher(flag uint32) (Watcher, error)
	GetResourceHeartbeatRspNotifier() (chan rpcpb.ResourceHeartbeatRsp, error)
}

Client prophet client

func NewClient

func NewClient(adapter metadata.Adapter, opts ...Option) Client

NewClient create a prophet client

type Option

type Option func(*options)

Option client option

func WithLeaderGetter

func WithLeaderGetter(value func() *metapb.Member) Option

WithLeaderGetter set a func to get a leader

func WithRPCTimeout

func WithRPCTimeout(value time.Duration) Option

WithRPCTimeout set rpc timeout

type Prophet

type Prophet interface {
	// Start start the prophet instance, this will start the lead election, heartbeat loop and listen requests
	Start()
	// Stop stop the prophet instance
	Stop()
	// GetStorage returns the storage
	GetStorage() storage.Storage
	// GetClient returns the prophet client
	GetClient() Client
	// GetLeader returns leader
	GetLeader() *metapb.Member
	// GetMember returns self
	GetMember() *member.Member
	// GetConfig returns cfg
	GetConfig() *config.Config
	// GetClusterID return cluster id
	GetClusterID() uint64
}

Prophet is the distributed scheduler and coordinator

func NewProphet

func NewProphet(cfg *config.Config) Prophet

NewProphet returns a prophet instance

type Watcher

type Watcher interface {
	// GetNotify returns event notify channel
	GetNotify() chan rpcpb.EventNotify
	// Close close watcher
	Close()
}

Watcher watcher

Jump to

Keyboard shortcuts

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