work

package
v1.10.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthWork        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowWork          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupWork = fmt.Errorf("proto: unexpected end of group")
)
View Source
var State_name = map[int32]string{
	0: "RUNNING",
	1: "SUCCESS",
	2: "FAILURE",
}
View Source
var State_value = map[string]int32{
	"RUNNING": 0,
	"SUCCESS": 1,
	"FAILURE": 2,
}

Functions

This section is empty.

Types

type CollectFunc

type CollectFunc func(context.Context, *Task) error

CollectFunc is a callback that is used for collecting the results from a subtask that has been processed.

type Master

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

Master is the master for a task. The master will layout the subtasks for the task in etcd and collect them upon completion. The collectFunc callback will be called for each subtask that is collected.

func NewMaster

func NewMaster(etcdClient *etcd.Client, etcdPrefix string, collectFunc CollectFunc) *Master

NewMaster creates a new master.

func (*Master) Run

func (m *Master) Run(ctx context.Context, task *Task) (retErr error)

Run runs the master with a given context and task.

type ProcessFunc

type ProcessFunc func(context.Context, *Task, *Task) error

ProcessFunc is a callback that is used for processing a subtask in a task.

type State

type State int32
const (
	State_RUNNING State = 0
	State_SUCCESS State = 1
	State_FAILURE State = 2
)

func (State) EnumDescriptor

func (State) EnumDescriptor() ([]byte, []int)

func (State) String

func (x State) String() string

type Task

type Task struct {
	Id                   string     `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
	Data                 *types.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
	Subtasks             []*Task    `protobuf:"bytes,3,rep,name=subtasks,proto3" json:"subtasks,omitempty"`
	XXX_NoUnkeyedLiteral struct{}   `json:"-"`
	XXX_unrecognized     []byte     `json:"-"`
	XXX_sizecache        int32      `json:"-"`
}

func (*Task) Descriptor

func (*Task) Descriptor() ([]byte, []int)

func (*Task) GetData

func (m *Task) GetData() *types.Any

func (*Task) GetId

func (m *Task) GetId() string

func (*Task) GetSubtasks

func (m *Task) GetSubtasks() []*Task

func (*Task) Marshal

func (m *Task) Marshal() (dAtA []byte, err error)

func (*Task) MarshalTo

func (m *Task) MarshalTo(dAtA []byte) (int, error)

func (*Task) MarshalToSizedBuffer

func (m *Task) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) Reset

func (m *Task) Reset()

func (*Task) Size

func (m *Task) Size() (n int)

func (*Task) String

func (m *Task) String() string

func (*Task) Unmarshal

func (m *Task) Unmarshal(dAtA []byte) error

func (*Task) XXX_DiscardUnknown

func (m *Task) XXX_DiscardUnknown()

func (*Task) XXX_Marshal

func (m *Task) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Task) XXX_Merge

func (m *Task) XXX_Merge(src proto.Message)

func (*Task) XXX_Size

func (m *Task) XXX_Size() int

func (*Task) XXX_Unmarshal

func (m *Task) XXX_Unmarshal(b []byte) error

type TaskInfo

type TaskInfo struct {
	Task                 *Task    `protobuf:"bytes,1,opt,name=task,proto3" json:"task,omitempty"`
	State                State    `protobuf:"varint,2,opt,name=state,proto3,enum=work.State" json:"state,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*TaskInfo) Descriptor

func (*TaskInfo) Descriptor() ([]byte, []int)

func (*TaskInfo) GetState

func (m *TaskInfo) GetState() State

func (*TaskInfo) GetTask

func (m *TaskInfo) GetTask() *Task

func (*TaskInfo) Marshal

func (m *TaskInfo) Marshal() (dAtA []byte, err error)

func (*TaskInfo) MarshalTo

func (m *TaskInfo) MarshalTo(dAtA []byte) (int, error)

func (*TaskInfo) MarshalToSizedBuffer

func (m *TaskInfo) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*TaskInfo) ProtoMessage

func (*TaskInfo) ProtoMessage()

func (*TaskInfo) Reset

func (m *TaskInfo) Reset()

func (*TaskInfo) Size

func (m *TaskInfo) Size() (n int)

func (*TaskInfo) String

func (m *TaskInfo) String() string

func (*TaskInfo) Unmarshal

func (m *TaskInfo) Unmarshal(dAtA []byte) error

func (*TaskInfo) XXX_DiscardUnknown

func (m *TaskInfo) XXX_DiscardUnknown()

func (*TaskInfo) XXX_Marshal

func (m *TaskInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*TaskInfo) XXX_Merge

func (m *TaskInfo) XXX_Merge(src proto.Message)

func (*TaskInfo) XXX_Size

func (m *TaskInfo) XXX_Size() int

func (*TaskInfo) XXX_Unmarshal

func (m *TaskInfo) XXX_Unmarshal(b []byte) error

type Worker

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

Worker is a worker that will process subtasks in a task. The worker will watch the task collection for tasks added by a master. When a task is added, the worker will claim and process subtasks associated with that task. The processFunc callback will be called for each subtask that needs to be processed in the task.

func NewWorker

func NewWorker(etcdClient *etcd.Client, etcdPrefix string, processFunc ProcessFunc) *Worker

NewWorker creates a new worker.

func (*Worker) Run

func (w *Worker) Run(ctx context.Context) error

Run runs the worker with the given context. The worker will continue to watch the task collection until the context is cancelled.

Jump to

Keyboard shortcuts

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