concurrency

package
v19.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2019 License: Apache-2.0 Imports: 14 Imported by: 44

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Trace = struct {
	Locks bool
	Tasks bool
}{
	false,
	false,
}

Trace contains what component in the package to trace

Functions

This section is empty.

Types

type Shielded

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

Shielded allows to store data with controlled access to it

func NewShielded

func NewShielded(witness data.Clonable) *Shielded

NewShielded creates a new protected data

func (*Shielded) Alter

func (d *Shielded) Alter(task Task, alterer func(data.Clonable) error) error

Alter allows to update a clonable using a write lock

func (*Shielded) Clone

func (d *Shielded) Clone() *Shielded

Clone ...

func (*Shielded) Inspect

func (d *Shielded) Inspect(task Task, inspector func(clonable data.Clonable) error) error

Inspect is used to lock a clonable for read

type Task

type Task interface {
	Abort()
	Aborted() bool
	ForceID(string) (Task, error)
	GetID() (string, error)
	GetSignature() string
	GetStatus() TaskStatus
	GetContext() context.Context
	Lock(TaskedLock)
	RLock(TaskedLock)
	Unlock(TaskedLock)
	RUnlock(TaskedLock)
	New() (Task, error)
	Reset() (Task, error)
	// GetResult() TaskResult
	Run(TaskAction, TaskParameters) (TaskResult, error)
	Start(TaskAction, TaskParameters) (Task, error)
	// StoreResult(TaskParameters)
	TryWait() (bool, TaskResult, error)
	Wait() (TaskResult, error)
}

Task ...

func NewTask

func NewTask(parentTask Task) (Task, error)

NewTask ...

func NewTaskGroup

func NewTaskGroup(parentTask Task) (Task, error)

NewTaskGroup ...

func NewTaskGroupWithContext

func NewTaskGroupWithContext(ctx context.Context) (Task, error)

NewTaskGroupWithContext ...

func NewTaskWithContext

func NewTaskWithContext(ctx context.Context) (Task, error)

NewTaskWithContext ...

func RootTask

func RootTask() Task

RootTask is the "task to rule them all"

func VoidTask

func VoidTask() (Task, error)

VoidTask is a new task that do nothing

type TaskAction

type TaskAction func(t Task, parameters TaskParameters) (TaskResult, error)

TaskAction ...

type TaskGroup

type TaskGroup interface {
	TryWait() (bool, map[string]TaskResult, error)
	Wait() (map[string]TaskResult, error)
	WaitFor(time.Duration) (bool, map[string]TaskResult, error)
}

TaskGroup is the task group interface

type TaskGroupResult

type TaskGroupResult map[string]TaskResult

TaskGroupResult is a map of the TaskResult of each task The index is the ID of the sub-Task running the action.

type TaskParameters

type TaskParameters interface{}

TaskParameters ...

type TaskResult

type TaskResult interface{}

TaskResult ...

type TaskStatus

type TaskStatus int

TaskStatus ...

const (

	// READY the task is ready to start
	READY TaskStatus
	// RUNNING the task is running
	RUNNING
	// DONE the task has run and is done
	DONE
	// ABORTED the task has been aborted
	ABORTED
)

type TaskedLock

type TaskedLock interface {
	RLock(Task)
	RUnlock(Task)
	Lock(Task)
	Unlock(Task)
	IsRLocked(Task) bool
	IsLocked(Task) bool
}

TaskedLock ...

func NewTaskedLock

func NewTaskedLock() TaskedLock

NewTaskedLock ...

type Tracer

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

Tracer ...

func NewTracer

func NewTracer(t Task, message string, enabled bool) *Tracer

NewTracer creates a new Tracer instance

func (*Tracer) GoingIn

func (t *Tracer) GoingIn() *Tracer

GoingIn logs the input message (signifying we are going in) using TRACE level

func (*Tracer) GoingInMessage

func (t *Tracer) GoingInMessage() string

GoingInMessage returns the content of the message when entering the function

func (*Tracer) GoingOut

func (t *Tracer) GoingOut() *Tracer

GoingOut logs the output message (signifying we are going out) using TRACE level and adds duration if WithStopwatch() has been called.

func (*Tracer) GoingOutMessage

func (t *Tracer) GoingOutMessage() string

GoingOutMessage returns the content of the message when exiting the function

func (*Tracer) OnExitTrace

func (t *Tracer) OnExitTrace() func()

OnExitTrace returns a function that will log the output message using TRACE level.

func (*Tracer) Stopwatch

func (t *Tracer) Stopwatch() temporal.Stopwatch

Stopwatch returns the stopwatch used (if a stopwatch has been asked with WithStopwatch() )

func (*Tracer) Trace

func (t *Tracer) Trace(format string, a ...interface{}) *Tracer

Trace traces a message

func (*Tracer) TraceMessage

func (t *Tracer) TraceMessage(format string, a ...interface{}) string

TraceMessage returns a string containing a trace message

func (*Tracer) WithStopwatch

func (t *Tracer) WithStopwatch() *Tracer

WithStopwatch will add a measure of duration between GoingIn and GoingOut. GoingOut will add the elapsed time in the log message (if it has to be logged...).

Jump to

Keyboard shortcuts

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