master

package
v0.0.0-...-278ce41 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourcePath = "/resources"

	ResourceAdd = iota
	ResourceDel
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command int

type Master

type Master struct {
	ID string

	IDGen *snowflake.Node
	// contains filtered or unexported fields
}

func New

func New(id string, opts ...Option) (*Master, error)

func (*Master) AddResource

func (m *Master) AddResource(ctx context.Context, req *pb.ResourceSpec, resp *pb.NodeSpec) error

func (*Master) AddResources

func (m *Master) AddResources(rs []*ResourceSpec)

func (*Master) AddSeed

func (m *Master) AddSeed()

func (*Master) Assign

func (m *Master) Assign(_ *ResourceSpec) (*NodeSpec, error)

func (*Master) BecomeLeader

func (m *Master) BecomeLeader() error

func (*Master) Campaign

func (m *Master) Campaign()

func (*Master) DelResource

func (m *Master) DelResource(ctx context.Context, spec *pb.ResourceSpec, _ *empty.Empty) error

func (*Master) IsLeader

func (m *Master) IsLeader() bool

func (*Master) SetForwardCli

func (m *Master) SetForwardCli(forwardCli crawler.CrawlerMasterService)

func (*Master) WatcherWorker

func (m *Master) WatcherWorker() chan *registry.Result

type Message

type Message struct {
	Cmd   Command
	Specs []*ResourceSpec
}

type NodeSpec

type NodeSpec struct {
	Node    *registry.Node
	Payload int // 负载
}

type Option

type Option func(opts *options)

func WithGRPCAddr

func WithGRPCAddr(addr string) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithRegistry

func WithRegistry(reg registry.Registry) Option

func WithRegistryURL

func WithRegistryURL(registryURL string) Option

func WithSeeds

func WithSeeds(seeds []*spider.Task) Option

type ResourceSpec

type ResourceSpec struct {
	ID           string
	Name         string
	AssignedNode string
	CreateTime   int64
}

func Decode

func Decode(ds []byte) (*ResourceSpec, error)

Jump to

Keyboard shortcuts

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