Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RuntimeContext ¶
RuntimeContext is used to store information related to the Runtime.
func NewRuntimeCtxWithSubmitTime ¶
func NewRuntimeCtxWithSubmitTime(ctx context.Context, submitTime clock.MonotonicTime) *RuntimeContext
NewRuntimeCtxWithSubmitTime creates a RuntimeContext with a given submit-time. This function is exposed for the purpose of unit-testing. There is NO NEED to use this function in production code.
func ToRuntimeCtx ¶
func ToRuntimeCtx(ctx context.Context) (rctx *RuntimeContext, ok bool)
ToRuntimeCtx tries to convert a plain context.Context to RuntimeContext. Returns (nil, false) if the argument is not derived from a RuntimeContext.
func (*RuntimeContext) SubmitTime ¶
func (c *RuntimeContext) SubmitTime() clock.MonotonicTime
SubmitTime returns the time at which a task is submitted to the runtime's queue.
type TaskCommitter ¶
type TaskCommitter struct {
// contains filtered or unexported fields
}
TaskCommitter is used to implement two-phase task dispatching.
func NewTaskCommitter ¶
func NewTaskCommitter(runner WrappedTaskAdder, requestTTL time.Duration) *TaskCommitter
NewTaskCommitter returns a TaskCommitter.
func (*TaskCommitter) Close ¶
func (c *TaskCommitter) Close()
Close terminates the background task of the TaskCommitter.
func (*TaskCommitter) ConfirmDispatchTask ¶
func (c *TaskCommitter) ConfirmDispatchTask(rID requestID, taskID RunnableID) (ok bool, retErr error)
ConfirmDispatchTask is the "commit" stage of dispatching a task. Return values: - (true, nil) is returned on success. - (false, nil) is returned if the PreDispatchTask request is not found in memory. - (false, [error]) is returned for other unexpected situations.
func (*TaskCommitter) PreDispatchTask ¶
func (c *TaskCommitter) PreDispatchTask(rID requestID, task Runnable) (ok bool)
PreDispatchTask is the "prepare" stage of submitting a task.
type TaskRunner ¶
type TaskRunner struct {
// contains filtered or unexported fields
}
TaskRunner receives RunnableContainer in a FIFO way, and runs them in independent background goroutines.
func NewTaskRunner ¶
func NewTaskRunner(inQueueSize int, initConcurrency int) *TaskRunner
NewTaskRunner creates a new TaskRunner instance
func (*TaskRunner) AddTask ¶
func (r *TaskRunner) AddTask(task Runnable) error
AddTask enqueues a naked task, and AddTask will wrap the task with internal.WrapRunnable. Deprecated. TODO Will be removed once two-phase task dispatching is enabled.
func (*TaskRunner) Run ¶
func (r *TaskRunner) Run(ctx context.Context) error
Run runs forever until context is canceled or task queue is closed. It receives new added task and call onNewTask with task
func (*TaskRunner) TaskCount ¶
func (r *TaskRunner) TaskCount() int64
TaskCount returns current task count
func (*TaskRunner) TaskStopReceiver ¶
func (r *TaskRunner) TaskStopReceiver() *notifier.Receiver[RunnableID]
TaskStopReceiver returns a *notifier.Notifier to notify when task is stopped.
func (*TaskRunner) WorkerCount ¶
func (r *TaskRunner) WorkerCount() int64
WorkerCount returns the number of currently running workers.
type WrappedTaskAdder ¶
type WrappedTaskAdder interface {
// contains filtered or unexported methods
}
WrappedTaskAdder is an interface used to abstract a TaskRunner.