pathtask

package
v0.0.0-...-86aba4e Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type Repo

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

func NewRepository

func NewRepository(db *sqlx.DB) *Repo

func (*Repo) Create

func (r *Repo) Create(from, to string) (*Task, error)

func (*Repo) Get

func (r *Repo) Get(id uuid.UUID) (*Task, error)

func (*Repo) SetResult

func (r *Repo) SetResult(id uuid.UUID, result *Result) error

func (*Repo) UpdateStatus

func (r *Repo) UpdateStatus(id uuid.UUID, oldStatus, newStatus Status) error

type Repository

type Repository interface {
	Create(from, to string) (*Task, error)
	Get(id uuid.UUID) (*Task, error)
	UpdateStatus(id uuid.UUID, oldStatus, newStatus Status) error
	SetResult(id uuid.UUID, result *Result) error
}

type Result

type Result struct {
	ShortestPath []string `json:"shortest_path"`
}

func (*Result) Scan

func (r *Result) Scan(value interface{}) error

func (*Result) Value

func (r *Result) Value() (driver.Value, error)

type Status

type Status uint
const (
	StatusPending Status = iota + 1
	StatusProcessing
	StatusDone
)

type Task

type Task struct {
	ID        uuid.UUID `db:"id"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`

	From string `db:"from_page"`
	To   string `db:"to_page"`

	Status Status `db:"status"`

	Result *Result `db:"result"`
}

Jump to

Keyboard shortcuts

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