task

package
v0.0.0-...-15a0c23 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package task describes task domain.

Index

Constants

View Source
const (
	Active   = Status("")
	Canceled = Status("canceled")
	Done     = Status("done")
	Expired  = Status("expired")
)

Available task statuses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Creator

type Creator interface {
	Create(context.Context, Value) (Entity, error)
}

Creator creates tasks.

type Entity

type Entity struct {
	Identity
	Value
	CreatedAt time.Time  `json:"createdAt"`
	Status    Status     `json:"status,omitempty"`
	ClosedAt  *time.Time `json:"closedAt,omitempty"`
}

Entity is an identified task entity.

type Finder

type Finder interface {
	Find(context.Context) []Entity
	FindByID(context.Context, Identity) (Entity, error)
}

Finder finds tasks.

type Finisher

type Finisher interface {
	Cancel(context.Context, Identity) error
	Finish(context.Context, Identity) error
}

Finisher closes tasks.

type Identity

type Identity struct {
	ID int `json:"id"`
}

Identity identifies task.

type Status

type Status string

Status describes task state.

func (Status) JSONSchema

func (Status) JSONSchema() (jsonschema.Schema, error)

JSONSchema exposes Status JSON schema, implements jsonschema.Exposer.

type Updater

type Updater interface {
	Update(context.Context, Identity, Value) error
}

Updater updates tasks.

type Value

type Value struct {
	Goal     string     `json:"goal" minLength:"1" required:"true"`
	Deadline *time.Time `json:"deadline,omitempty"`
}

Value is a task value.

Jump to

Keyboard shortcuts

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