master

package
v0.0.0-...-0583c98 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(s *TaskSpec) string

func GetNodeID

func GetNodeID(name string) (string, error)

Types

type AreaAssigner

type AreaAssigner struct{}

type Assigner

type Assigner interface {
	Assign(workNodes map[string]*registry.Node) (*registry.Node, error)
}

type Master

type Master struct {
	ID  string
	Loc string

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

func New

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

func (*Master) AddTask

func (m *Master) AddTask(assigner Assigner, tasks ...*TaskSpec)

func (*Master) BecomeLeader

func (m *Master) BecomeLeader() error

func (*Master) Campaign

func (m *Master) Campaign()

func (*Master) IsLeader

func (m *Master) IsLeader() bool

func (*Master) PushTask

func (m *Master) PushTask(ctx context.Context, ptask *publisher.TaskSpec, out *empty.Empty) error

PushTask implement grpc call

func (*Master) Run

func (m *Master) Run()

func (*Master) SetForwardCli

func (m *Master) SetForwardCli(cli publisher.PublisherService)

func (*Master) WatchWorker

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

type Setup

type Setup func(opts *options)

func WithContext

func WithContext(ctx context.Context) Setup

func WithGRPCAddress

func WithGRPCAddress(GRPCAddress string) Setup

func WithLogger

func WithLogger(logger *zap.Logger) Setup

func WithRegistry

func WithRegistry(registry registry.Registry) Setup

func WithregistryURL

func WithregistryURL(registryURL string) Setup

type SimpleAssigner

type SimpleAssigner struct{}

func (*SimpleAssigner) Assign

func (s *SimpleAssigner) Assign(workNodes map[string]*registry.Node) (*registry.Node, error)

Assign :a random balacner

type TaskSpec

type TaskSpec struct {
	ID           string
	Name         string
	AssgnedNode  string
	CreationTime int64

	SumName string
	Type    string
	Loc     string
}

func Decode

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

Jump to

Keyboard shortcuts

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