master

package
v0.0.0-...-caa0154 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RESOURCE_PATH = "/resources"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command int
const (
	MSGADD Command = iota
	MSGDELETE
)

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 *proto.ResourceSpec, resp *proto.NodeSpec) error

资源管理

func (*Master) AddResources

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

func (*Master) DeleteResource

func (m *Master) DeleteResource(ctx context.Context, spec *proto.ResourceSpec, empty *empty.Empty) error

func (*Master) SetForwardClient

func (m *Master) SetForwardClient(cli proto.CrawlerMasterService)

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 WithGRPCAddress

func WithGRPCAddress(GRPCAddress string) Option

func WithLogger

func WithLogger(logger *zap.Logger) Option

func WithRegistry

func WithRegistry(registry registry.Registry) Option

func WithSeeds

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

func WithregistryURL

func WithregistryURL(registryURL string) Option

type ResourceSpec

type ResourceSpec struct {
	Id           string
	Name         string
	AssignedNode string
	CreatedTime  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