task

package
v0.0.2-0...-9a6aa9e Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDuration = 25 * time.Minute
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailableAction

type AvailableAction int
const (
	AvailableActionStart AvailableAction = iota
	AvailableActionPause
	AvailableActionResume
	AvailableActionStop
	AvailableActionSwitch
)

func (AvailableAction) String

func (i AvailableAction) String() string

type Duration

type Duration interface {
	Value() int64
}

func NewDuration

func NewDuration(value int64) (Duration, error)

type Elapsed

type Elapsed interface {
	Value() int64
}

func NewElapsed

func NewElapsed(value int64) (Elapsed, error)

type InvalidStatusTransition

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

func NewInvalidStatusTransition

func NewInvalidStatusTransition(msg string) *InvalidStatusTransition

func (*InvalidStatusTransition) Error

func (e *InvalidStatusTransition) Error() string

type Name

type Name interface {
	Value() string
}

func NewName

func NewName(name string) (Name, error)

type Repository

type Repository interface {
	GetCurrent() Task
	Save(t Task)
}

type StartedAt

type StartedAt interface {
	Value() int64
}

func NewStartedAt

func NewStartedAt(value int64) (StartedAt, error)

type Status

type Status interface {
	Value() StatusValue
	Update(to Status) error
}

func NewStatus

func NewStatus(s StatusValue) Status

func NewStatusFromString

func NewStatusFromString(s string) (Status, error)

type StatusValue

type StatusValue string
const (
	TaskStatusNone     StatusValue = "none"
	TaskStatusRunning  StatusValue = "running"
	TaskStatusPaused   StatusValue = "paused"
	TaskStatusStopped  StatusValue = "aborted"
	TaskStatusFinished StatusValue = "finished"
)

type Task

type Task interface {
	// props
	Name() Name
	Duration() Duration
	StartedAt() StartedAt
	Elapsed() Elapsed
	Status() Status
	AvailableActions() []AvailableAction
	// behaviors
	Start(at time.Time) error
	Pause() error
	Resume(at time.Time) error
	Stop() error
	Finish() error
	CanStart() bool
	CanPause() bool
	CanResume() bool
	CanStop() bool
	CanFinish() bool
}

func NewTask

func NewTask(name Name, d Duration) Task

func NewTaskWithValues

func NewTaskWithValues(
	name Name,
	duration Duration,
	startedAt StartedAt,
	elapsed Elapsed,
	status Status,
) Task

type TaskFinished

type TaskFinished interface {
	event.Event
	Name() Name
	StartedAt() StartedAt
	Duration() Duration
	Elapsed() Elapsed
	Status() Status
}

func NewTaskFinished

func NewTaskFinished(name Name, startedAt StartedAt, duration Duration, elapsed Elapsed, status Status) TaskFinished

type TaskPaused

type TaskPaused interface {
	event.Event
	Name() Name
	StartedAt() StartedAt
	Duration() Duration
	Elapsed() Elapsed
	Status() Status
}

func NewTaskPaused

func NewTaskPaused(name Name, startedAt StartedAt, duration Duration, elapsed Elapsed, status Status) TaskPaused

type TaskResumed

type TaskResumed interface {
	event.Event
	Name() Name
	StartedAt() StartedAt
	Duration() Duration
	Elapsed() Elapsed
	Status() Status
}

func NewTaskResumed

func NewTaskResumed(name Name, startedAt StartedAt, duration Duration, elapsed Elapsed, status Status) TaskResumed

type TaskService

type TaskService interface {
	SwitchTask(name Name, duration Duration) (Task, error)
}

func NewTaskService

func NewTaskService(repository Repository) TaskService

type TaskStarted

type TaskStarted interface {
	event.Event
	Name() Name
	StartedAt() StartedAt
	Duration() Duration
	Elapsed() Elapsed
}

func NewTaskStarted

func NewTaskStarted(name Name, startedAt StartedAt, duration Duration, elapsed Elapsed) TaskStarted

type TaskStopped

type TaskStopped interface {
	event.Event
	Name() Name
	StartedAt() StartedAt
	Duration() Duration
	Elapsed() Elapsed
	Status() Status
}

func NewTaskStopped

func NewTaskStopped(name Name, startedAt StartedAt, duration Duration, elapsed Elapsed, status Status) TaskStopped

Jump to

Keyboard shortcuts

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