tonight

package module
v0.0.0-...-9678f86 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2020 License: MIT Imports: 9 Imported by: 0

README

Tonight

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterHTTP

func RegisterHTTP(
	srv *echo.Group,
	eventStore EventStore,
	taskStore TaskStore,
	projectStore ProjectStore,
	releaseStore ReleaseStore,
	userStore UserStore,
) error

Types

type Event

type Event struct {
	UUID       uuid.UUID
	Type       EventType
	EntityUUID uuid.UUID
	UserID     string
	Payload    []byte
	CreatedAt  time.Time
}

An Event is used to record every mutation requested by users.

type EventStore

type EventStore interface {
	// Store e in the database/store.
	Store(ctx context.Context, e Event) error

	// List all the events from the store. List takes
	// a channel as input to make it more convenient
	// to scroll through all the events stored.
	List(ctx context.Context, ch chan<- Event) error
}

An EventStore should store and retrieve Events.

type EventType

type EventType string
const (
	TaskCreate EventType = "TaskCreate"
	TaskUpdate EventType = "TaskUpdate"
	TaskDone   EventType = "TaskDone"

	ReleaseCreate EventType = "ReleaseCreate"

	ProjectCreate       EventType = "ProjectCreate"
	ProjectUpdate       EventType = "ProjectUpdate"
	ProjectReorderTasks EventType = "ProjectReorderTasks"
)

Event types

type Project

type Project struct {
	UUID uuid.UUID `json:"uuid"`

	Name string `json:"name"`
	Slug string `json:"slug"`

	Description string `json:"description"`

	Releases []Release `json:"releases"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Project groups tasks.

type ProjectStore

type ProjectStore interface {
	Upsert(ctx context.Context, p Project, u User) error
	List(ctx context.Context, u User) ([]Project, error)
	Get(ctx context.Context, uuid uuid.UUID, u User) (Project, error)

	Find(ctx context.Context, slug string, u User) (Project, error)
}

A ProjectStore is responsible for storing projects, typically in a database.

type Release

type Release struct {
	UUID uuid.UUID `json:"uuid"`

	Title       string `json:"title"`
	Description string `json:"description"`

	Project Project `json:"project"`
	Tasks   []Task  `json:"tasks"`

	CreatedAt time.Time `json:"createdat"`
	UpdatedAt time.Time `json:"updatedat"`
}

type ReleaseStore

type ReleaseStore interface {
	Get(ctx context.Context, id uuid.UUID) (Release, error)
	List(ctx context.Context, projectUUID uuid.UUID) ([]Release, error)

	Upsert(ctx context.Context, release Release) error
}

type Task

type Task struct {
	UUID uuid.UUID `json:"uuid"`

	Title  string     `json:"title"`
	Status TaskStatus `json:"status"`

	Release Release `json:"release"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

A Task is the basic object of Tonight.

type TaskStatus

type TaskStatus string
const (
	TaskStatusTODO TaskStatus = "TODO"
	TaskStatusDONE TaskStatus = "DONE"
)

type TaskStore

type TaskStore interface {
	Upsert(ctx context.Context, t Task) error
	Get(ctx context.Context, uuid uuid.UUID, u User) (Task, error)

	Reorder(ctx context.Context, rankedUUIDs []uuid.UUID) error
}

A TaskStore is responsible for storing tasks, typically in a database.

type User

type User struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type UserStore

type UserStore interface {
	Ensure(ctx context.Context, user *User) error
	Permission(ctx context.Context, user User, projectUUID string) (string, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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