storage

package
v0.0.0-...-16fbdda Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")

Functions

This section is empty.

Types

type Job

type Job struct {
	ID       int64
	ReportID int64
	Label    string
}

func MakeJob

func MakeJob(report Report, label string) Job

type Line

type Line struct {
	ID    int64
	JobID int64
	Error int
	Text  string
}

type ReadJob

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

ReadJob implements job.Job by reading Lines from a channel and making them available to the Stdout() and Stderr() Readers through a Pipe.

func NewReadJob

func NewReadJob(stdout io.Reader, stderr io.Reader, job Job, report Report) *ReadJob

func (*ReadJob) Do

func (rj *ReadJob) Do(ctx context.Context) *job.Waiter

func (*ReadJob) Label

func (rj *ReadJob) Label() string

func (*ReadJob) Selector

func (rj *ReadJob) Selector() string

type Report

type Report struct {
	ID        int64
	CreatedAt time.Time
	Name      string
	Input     string
}

func MakeReport

func MakeReport() Report

MakeReport returns a Report with generated names and timestamps.

type Repository

type Repository interface {
	Reports() ([]Report, error)
	LastReport() (Report, error)
	Report(name string) (Report, error)

	JobsByReport(r Report) ([]Job, error)

	InsertReport(report *Report) error
	InsertJob(job *Job) error
	InsertLine(line *Line) error

	JobReaders(j Job) (io.Reader, io.Reader)
}

A Repository is used by the Store to perform actual read and writes to some storage backend.

type Store

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

A Store provides methods to read and write job.Job's outputs.

func NewStore

func NewStore(repo Repository) *Store

func (*Store) LastReport

func (s *Store) LastReport() (Report, error)

LastReport retrieves the most recent report

func (*Store) ListReports

func (s *Store) ListReports() ([]Report, error)

ListReports lists all the reports

func (*Store) Replay

func (s *Store) Replay(report Report) ([]wjob.Job, error)

Replay takes a Report and returns Jobs that when run will emit the data stored for it.

func (*Store) Report

func (s *Store) Report(name string) (Report, error)

Report retrieves one report by name

func (*Store) Wrap

func (s *Store) Wrap(jobs []wjob.Job, input io.Reader) (context.Context, []wjob.Job, error)

Wrap takes some Jobs and sets them up so that when they are run, their STDOUT and STDERR will also be stored.

type WriteJob

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

WriteJob implements job.Job by scanning another job.Job's Stdout() and Stderr() and writing each line as an instance of Line to the lines channel.

func NewWriteJob

func NewWriteJob(j job.Job, lines chan<- Line) *WriteJob

func (*WriteJob) Do

func (dj *WriteJob) Do(ctx context.Context) *job.Waiter

func (*WriteJob) Label

func (dj *WriteJob) Label() string

func (*WriteJob) Selector

func (dj *WriteJob) Selector() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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