Documentation ¶
Index ¶
- Variables
- func Count(ctx context.Context, service Service, namespace, group string) (tasks int64, claims int64, retErr error)
- func DoBatch(ctx context.Context, doer Doer, inputs []*anypb.Any, cb CollectFunc) error
- func DoOne(ctx context.Context, doer Doer, input *anypb.Any) (*anypb.Any, error)
- func DoOrdered(ctx context.Context, doer Doer, inputs chan *anypb.Any, parallelism int, ...) error
- func List(ctx context.Context, svc Service, req *taskapi.ListTaskRequest, ...) error
- type Cache
- type Claim
- func (*Claim) Descriptor() ([]byte, []int)deprecated
- func (x *Claim) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (*Claim) ProtoMessage()
- func (x *Claim) ProtoReflect() protoreflect.Message
- func (x *Claim) Reset()
- func (x *Claim) String() string
- func (m *Claim) Validate() error
- func (m *Claim) ValidateAll() error
- type ClaimMultiError
- type ClaimValidationError
- type CollectFunc
- type Doer
- type Group
- func (*Group) Descriptor() ([]byte, []int)deprecated
- func (x *Group) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (*Group) ProtoMessage()
- func (x *Group) ProtoReflect() protoreflect.Message
- func (x *Group) Reset()
- func (x *Group) String() string
- func (m *Group) Validate() error
- func (m *Group) ValidateAll() error
- type GroupMultiError
- type GroupValidationError
- type ProcessFunc
- type Service
- type Source
- type State
- type Task
- func (*Task) Descriptor() ([]byte, []int)deprecated
- func (x *Task) GetId() string
- func (x *Task) GetIndex() int64
- func (x *Task) GetInput() *anypb.Any
- func (x *Task) GetOutput() *anypb.Any
- func (x *Task) GetReason() string
- func (x *Task) GetState() State
- func (x *Task) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (*Task) ProtoMessage()
- func (x *Task) ProtoReflect() protoreflect.Message
- func (x *Task) Reset()
- func (x *Task) String() string
- func (m *Task) Validate() error
- func (m *Task) ValidateAll() error
- type TaskMultiError
- type TaskValidationError
- type TestTask
- func (*TestTask) Descriptor() ([]byte, []int)deprecated
- func (x *TestTask) GetId() string
- func (x *TestTask) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (*TestTask) ProtoMessage()
- func (x *TestTask) ProtoReflect() protoreflect.Message
- func (x *TestTask) Reset()
- func (x *TestTask) String() string
- func (m *TestTask) Validate() error
- func (m *TestTask) ValidateAll() error
- type TestTaskMultiError
- type TestTaskValidationError
Constants ¶
This section is empty.
Variables ¶
var ( State_name = map[int32]string{ 0: "STATE_UNKNOWN", 1: "RUNNING", 2: "SUCCESS", 3: "FAILURE", } State_value = map[string]int32{ "STATE_UNKNOWN": 0, "RUNNING": 1, "SUCCESS": 2, "FAILURE": 3, } )
Enum value maps for State.
var File_internal_task_task_proto protoreflect.FileDescriptor
Functions ¶
func Count ¶
func Count(ctx context.Context, service Service, namespace, group string) (tasks int64, claims int64, retErr error)
Count returns the number of tasks and claims in the given namespace and group (if nonempty)
func DoOne ¶
DoOne executes one task. NOTE: This interface is much less performant than the stream / batch interfaces for many tasks. Only use this interface for development / a small number of tasks.
Types ¶
type Claim ¶
type Claim struct {
// contains filtered or unexported fields
}
func (*Claim) Descriptor
deprecated
func (*Claim) MarshalLogObject ¶
func (x *Claim) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Claim) ProtoMessage ¶
func (*Claim) ProtoMessage()
func (*Claim) ProtoReflect ¶ added in v2.7.0
func (x *Claim) ProtoReflect() protoreflect.Message
func (*Claim) Validate ¶ added in v2.8.0
Validate checks the field values on Claim with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Claim) ValidateAll ¶ added in v2.8.0
ValidateAll checks the field values on Claim with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in ClaimMultiError, or nil if none found.
type ClaimMultiError ¶ added in v2.8.0
type ClaimMultiError []error
ClaimMultiError is an error wrapping multiple validation errors returned by Claim.ValidateAll() if the designated constraints aren't met.
func (ClaimMultiError) AllErrors ¶ added in v2.8.0
func (m ClaimMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (ClaimMultiError) Error ¶ added in v2.8.0
func (m ClaimMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type ClaimValidationError ¶ added in v2.8.0
type ClaimValidationError struct {
// contains filtered or unexported fields
}
ClaimValidationError is the validation error returned by Claim.Validate if the designated constraints aren't met.
func (ClaimValidationError) Cause ¶ added in v2.8.0
func (e ClaimValidationError) Cause() error
Cause function returns cause value.
func (ClaimValidationError) Error ¶ added in v2.8.0
func (e ClaimValidationError) Error() string
Error satisfies the builtin error interface
func (ClaimValidationError) ErrorName ¶ added in v2.8.0
func (e ClaimValidationError) ErrorName() string
ErrorName returns error name.
func (ClaimValidationError) Field ¶ added in v2.8.0
func (e ClaimValidationError) Field() string
Field function returns field value.
func (ClaimValidationError) Key ¶ added in v2.8.0
func (e ClaimValidationError) Key() bool
Key function returns key value.
func (ClaimValidationError) Reason ¶ added in v2.8.0
func (e ClaimValidationError) Reason() string
Reason function returns reason value.
type CollectFunc ¶
CollectFunc is the type of a function that is used for collecting the output of a stream / batch of tasks. Index is the index of a task with respect to the order in which the task was created in the stream / batch.
type Doer ¶
type Doer interface { // Do creates and returns the results of processing a stream of tasks provided // by the input channel. The client should close the input channel when all tasks have // been sent (it does not need to be closed if the context is canceled). For each // task, the collect function will be called with the results. Do(ctx context.Context, inputChan chan *anypb.Any, cb CollectFunc) error }
Doer is a doer of tasks. Refer to the DoOne and DoBatch helper functions if a simpler interface is desired.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Descriptor
deprecated
func (*Group) MarshalLogObject ¶
func (x *Group) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Group) ProtoMessage ¶
func (*Group) ProtoMessage()
func (*Group) ProtoReflect ¶ added in v2.7.0
func (x *Group) ProtoReflect() protoreflect.Message
func (*Group) Validate ¶ added in v2.8.0
Validate checks the field values on Group with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Group) ValidateAll ¶ added in v2.8.0
ValidateAll checks the field values on Group with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in GroupMultiError, or nil if none found.
type GroupMultiError ¶ added in v2.8.0
type GroupMultiError []error
GroupMultiError is an error wrapping multiple validation errors returned by Group.ValidateAll() if the designated constraints aren't met.
func (GroupMultiError) AllErrors ¶ added in v2.8.0
func (m GroupMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (GroupMultiError) Error ¶ added in v2.8.0
func (m GroupMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type GroupValidationError ¶ added in v2.8.0
type GroupValidationError struct {
// contains filtered or unexported fields
}
GroupValidationError is the validation error returned by Group.Validate if the designated constraints aren't met.
func (GroupValidationError) Cause ¶ added in v2.8.0
func (e GroupValidationError) Cause() error
Cause function returns cause value.
func (GroupValidationError) Error ¶ added in v2.8.0
func (e GroupValidationError) Error() string
Error satisfies the builtin error interface
func (GroupValidationError) ErrorName ¶ added in v2.8.0
func (e GroupValidationError) ErrorName() string
ErrorName returns error name.
func (GroupValidationError) Field ¶ added in v2.8.0
func (e GroupValidationError) Field() string
Field function returns field value.
func (GroupValidationError) Key ¶ added in v2.8.0
func (e GroupValidationError) Key() bool
Key function returns key value.
func (GroupValidationError) Reason ¶ added in v2.8.0
func (e GroupValidationError) Reason() string
Reason function returns reason value.
type ProcessFunc ¶
ProcessFunc is the type of a function that is use for processing a task. If an error occurs, then it should be returned. This error will be propagated back to the Doer that created the task.
type Service ¶
type Service interface { // NewDoer creates a Doer with the provided namespace and group. NewDoer(namespace, group string, cache Cache) Doer // NewSource creates a Source with the provided namespace. NewSource(namespace string) Source // List calls a function on every task under a namespace and group List(ctx context.Context, namespace, group string, cb func(namespace, group string, data *Task, claimed bool) error) error }
Scheduling: A task managed by a Service has a group. The group is used for scheduling purposes. Scheduling is based on maximizing fairness for the groups, and the schedulable unit is a task.
type Source ¶
type Source interface { // Iterate iterates through tasks until the provided context is canceled. // For each task, the process function will be called and the results // will be returned to the Doer that created the task. Iterate(ctx context.Context, cb ProcessFunc) error }
Source is a source of tasks.
type State ¶
type State int32
func (State) Descriptor ¶ added in v2.7.0
func (State) Descriptor() protoreflect.EnumDescriptor
func (State) EnumDescriptor
deprecated
func (State) Number ¶ added in v2.7.0
func (x State) Number() protoreflect.EnumNumber
func (State) Type ¶ added in v2.7.0
func (State) Type() protoreflect.EnumType
type Task ¶
type Task struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` State State `protobuf:"varint,2,opt,name=state,proto3,enum=task.State" json:"state,omitempty"` Input *anypb.Any `protobuf:"bytes,3,opt,name=input,proto3" json:"input,omitempty"` Output *anypb.Any `protobuf:"bytes,4,opt,name=output,proto3" json:"output,omitempty"` Reason string `protobuf:"bytes,5,opt,name=reason,proto3" json:"reason,omitempty"` Index int64 `protobuf:"varint,6,opt,name=index,proto3" json:"index,omitempty"` // contains filtered or unexported fields }
TODO: Consider splitting this up into separate structures for each state in a oneof.
func (*Task) Descriptor
deprecated
func (*Task) MarshalLogObject ¶
func (x *Task) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*Task) ProtoMessage ¶
func (*Task) ProtoMessage()
func (*Task) ProtoReflect ¶ added in v2.7.0
func (x *Task) ProtoReflect() protoreflect.Message
func (*Task) Validate ¶ added in v2.8.0
Validate checks the field values on Task with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Task) ValidateAll ¶ added in v2.8.0
ValidateAll checks the field values on Task with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TaskMultiError, or nil if none found.
type TaskMultiError ¶ added in v2.8.0
type TaskMultiError []error
TaskMultiError is an error wrapping multiple validation errors returned by Task.ValidateAll() if the designated constraints aren't met.
func (TaskMultiError) AllErrors ¶ added in v2.8.0
func (m TaskMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (TaskMultiError) Error ¶ added in v2.8.0
func (m TaskMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type TaskValidationError ¶ added in v2.8.0
type TaskValidationError struct {
// contains filtered or unexported fields
}
TaskValidationError is the validation error returned by Task.Validate if the designated constraints aren't met.
func (TaskValidationError) Cause ¶ added in v2.8.0
func (e TaskValidationError) Cause() error
Cause function returns cause value.
func (TaskValidationError) Error ¶ added in v2.8.0
func (e TaskValidationError) Error() string
Error satisfies the builtin error interface
func (TaskValidationError) ErrorName ¶ added in v2.8.0
func (e TaskValidationError) ErrorName() string
ErrorName returns error name.
func (TaskValidationError) Field ¶ added in v2.8.0
func (e TaskValidationError) Field() string
Field function returns field value.
func (TaskValidationError) Key ¶ added in v2.8.0
func (e TaskValidationError) Key() bool
Key function returns key value.
func (TaskValidationError) Reason ¶ added in v2.8.0
func (e TaskValidationError) Reason() string
Reason function returns reason value.
type TestTask ¶
type TestTask struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // contains filtered or unexported fields }
func (*TestTask) Descriptor
deprecated
func (*TestTask) MarshalLogObject ¶
func (x *TestTask) MarshalLogObject(enc zapcore.ObjectEncoder) error
func (*TestTask) ProtoMessage ¶
func (*TestTask) ProtoMessage()
func (*TestTask) ProtoReflect ¶ added in v2.7.0
func (x *TestTask) ProtoReflect() protoreflect.Message
func (*TestTask) Validate ¶ added in v2.8.0
Validate checks the field values on TestTask with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*TestTask) ValidateAll ¶ added in v2.8.0
ValidateAll checks the field values on TestTask with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in TestTaskMultiError, or nil if none found.
type TestTaskMultiError ¶ added in v2.8.0
type TestTaskMultiError []error
TestTaskMultiError is an error wrapping multiple validation errors returned by TestTask.ValidateAll() if the designated constraints aren't met.
func (TestTaskMultiError) AllErrors ¶ added in v2.8.0
func (m TestTaskMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (TestTaskMultiError) Error ¶ added in v2.8.0
func (m TestTaskMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type TestTaskValidationError ¶ added in v2.8.0
type TestTaskValidationError struct {
// contains filtered or unexported fields
}
TestTaskValidationError is the validation error returned by TestTask.Validate if the designated constraints aren't met.
func (TestTaskValidationError) Cause ¶ added in v2.8.0
func (e TestTaskValidationError) Cause() error
Cause function returns cause value.
func (TestTaskValidationError) Error ¶ added in v2.8.0
func (e TestTaskValidationError) Error() string
Error satisfies the builtin error interface
func (TestTaskValidationError) ErrorName ¶ added in v2.8.0
func (e TestTaskValidationError) ErrorName() string
ErrorName returns error name.
func (TestTaskValidationError) Field ¶ added in v2.8.0
func (e TestTaskValidationError) Field() string
Field function returns field value.
func (TestTaskValidationError) Key ¶ added in v2.8.0
func (e TestTaskValidationError) Key() bool
Key function returns key value.
func (TestTaskValidationError) Reason ¶ added in v2.8.0
func (e TestTaskValidationError) Reason() string
Reason function returns reason value.