task

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleAsLeader

func HandleAsLeader(ctx context.Context, nl net.Listener, dp string, cond *sync.Cond, job *models.Job)

func HandleAsWorker

func HandleAsWorker(ctx context.Context, addr string, storages []types.Storager)

Types

type Leader

type Leader struct {
	models.UnimplementedWorkerServer
	// contains filtered or unexported fields
}

func NewLeader

func NewLeader(ctx context.Context,
	nl net.Listener,
	databasePath string,
	job *models.Job,
) (l *Leader, err error)

func (*Leader) CreateJob

func (l *Leader) CreateJob(ctx context.Context, req *models.CreateJobRequest) (reply *models.CreateJobReply, err error)

func (*Leader) FinishJob

func (l *Leader) FinishJob(ctx context.Context, req *models.FinishJobRequest) (reply *models.FinishJobReply, err error)

func (*Leader) PollJob

func (l *Leader) PollJob(req *models.PollJobRequest, srv models.Worker_PollJobServer) (err error)

func (*Leader) Serve

func (l *Leader) Serve(ctx context.Context) (err error)

func (*Leader) WaitJob

func (l *Leader) WaitJob(ctx context.Context, req *models.WaitJobRequest) (reply *models.WaitJobReply, err error)

type Manager

type Manager struct {
	models.UnimplementedStaffServer
	// contains filtered or unexported fields
}

func NewManager

func NewManager(ctx context.Context, cfg ManagerConfig) (p *Manager, err error)

func (*Manager) DB

func (p *Manager) DB() *models.DB

func (*Manager) Elect

func (p *Manager) Elect(ctx context.Context, req *models.ElectRequest) (reply *models.ElectReply, err error)

func (*Manager) Finish

func (p *Manager) Finish(ctx context.Context, req *models.FinishRequest) (reply *models.FinishReply, err error)

func (*Manager) Poll

func (p *Manager) Poll(req *models.PollRequest, srv models.Staff_PollServer) (err error)

func (*Manager) Register

func (p *Manager) Register(ctx context.Context, req *models.RegisterRequest) (reply *models.RegisterReply, err error)

func (*Manager) Stop

func (p *Manager) Stop(ctx context.Context) (err error)

type ManagerConfig

type ManagerConfig struct {
	Host     string
	GrpcPort int

	DatabasePath string
}

func (ManagerConfig) GrpcAddr

func (p ManagerConfig) GrpcAddr() string

type Staff

type Staff struct {
	// contains filtered or unexported fields
}

func NewStaff

func NewStaff(ctx context.Context, cfg StaffConfig) (s *Staff, err error)

func (*Staff) FinishTask

func (s *Staff) FinishTask(ctx context.Context, taskId string) (err error)

func (*Staff) Start

func (s *Staff) Start(ctx context.Context) (err error)

Connect will connect to portal task queue.

type StaffConfig

type StaffConfig struct {
	Host     string
	DataPath string

	ManagerAddr string
}

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(ctx context.Context, addr string, storages []types.Storager) (w *Worker, err error)

func (*Worker) Serve

func (w *Worker) Serve(ctx context.Context) (err error)

Jump to

Keyboard shortcuts

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