cache

package
v0.0.0-...-5415481 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2019 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentSchema = `` /* 3340-byte string literal not displayed */

Variables

This section is empty.

Functions

func NullTimeFromString

func NullTimeFromString(s string) (t sql.NullTime, err error)

func WriteLogs

func WriteLogs(jobs []Job, dir string) (paths []string, err error)

Types

type Account

type Account struct {
	ID       string
	URL      string
	UserID   string
	Username string
}

type Build

type Build struct {
	AccountID       string
	ID              int
	RepositoryURL   string
	CommitID        string
	Ref             string
	IsTag           bool
	RepoBuildNumber string
	State           State
	CreatedAt       sql.NullTime
	StartedAt       sql.NullTime
	FinishedAt      sql.NullTime
	UpdatedAt       time.Time
	Duration        sql.NullInt64
	WebURL          string
}

type Cache

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

func NewCache

func NewCache(filePath string, removeExisting bool, requesters []Requester) (Cache, error)

func TemporaryCache

func TemporaryCache(ctx context.Context, name string, inserters []Inserter) (Cache, error)

func (Cache) Close

func (c Cache) Close() (err error)

func (Cache) FetchJobs

func (c Cache) FetchJobs(ctx context.Context, jobsKeys []JobKey) ([]Job, error)

func (*Cache) NewRepositoryBuilds

func (c *Cache) NewRepositoryBuilds(repositoryURL string, updates chan time.Time) RepositoryBuilds

func (Cache) Save

func (c Cache) Save(ctx context.Context, inserters []Inserter) (err error)

Serialize write operations for safe use across multiple goroutines FIXME This will break with multiple instances of citop accessing the same

cache database ==> Check for sqlite BUSY error

type Commit

type Commit struct {
	AccountID     string
	ID            string
	RepositoryURL string
	Message       string
	Date          sql.NullTime
}

type HierarchicalTabularDataSource

type HierarchicalTabularDataSource interface {
	SetTraversable(key interface{}, traversable bool)
	FetchRows() error
	Select(key interface{}, nbrBefore int, nbrAfter int) ([]TabularSourceRow, int, error)
	SelectFirst(limit int) ([]TabularSourceRow, error)
	SelectLast(limit int) ([]TabularSourceRow, error)
	WriteToDirectory(ctx context.Context, key interface{}, tmpDir string) ([]string, error)
	MaxWidths() map[string]int
}

type Inserter

type Inserter interface {
	// contains filtered or unexported methods
}

type Job

type Job struct {
	Key        JobKey
	State      State
	Name       string
	CreatedAt  sql.NullTime
	StartedAt  sql.NullTime
	FinishedAt sql.NullTime
	Duration   sql.NullInt64
	Log        string
}

type JobKey

type JobKey struct {
	AccountID string
	BuildID   int
	StageID   int
	ID        int
}

type Repository

type Repository struct {
	AccountID string
	URL       string
	Owner     string
	Name      string
	RemoteID  int
}

func (Repository) Slug

func (r Repository) Slug() string

type RepositoryBuilds

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

func (*RepositoryBuilds) FetchData

func (s *RepositoryBuilds) FetchData(ctx context.Context, updates chan time.Time) error

func (*RepositoryBuilds) FetchRows

func (s *RepositoryBuilds) FetchRows() (err error)

func (RepositoryBuilds) MaxWidths

func (s RepositoryBuilds) MaxWidths() map[string]int

func (*RepositoryBuilds) Select

func (s *RepositoryBuilds) Select(key interface{}, nbrBefore int, nbrAfter int) ([]TabularSourceRow, int, error)

func (*RepositoryBuilds) SelectFirst

func (s *RepositoryBuilds) SelectFirst(limit int) ([]TabularSourceRow, error)

func (*RepositoryBuilds) SelectLast

func (s *RepositoryBuilds) SelectLast(limit int) ([]TabularSourceRow, error)

func (*RepositoryBuilds) SetTraversable

func (s *RepositoryBuilds) SetTraversable(key interface{}, traversable bool)

func (RepositoryBuilds) WriteToDirectory

func (s RepositoryBuilds) WriteToDirectory(ctx context.Context, key interface{}, dir string) ([]string, error)

type Requester

type Requester interface {
	AccountID() string
	Builds(ctx context.Context, repository Repository, duration time.Duration, inserters chan<- []Inserter) error
	Repository(ctx context.Context, repositoryURL string) (Repository, error)
}

FIXME Find a better name

type Stage

type Stage struct {
	AccountID string
	BuildID   int
	ID        int
	Name      string
	State     State
}

type State

type State string
const (
	Unknown  State = "?"
	Pending  State = "pending"
	Running  State = "running"
	Passed   State = "passed"
	Failed   State = "failed"
	Canceled State = "canceled"
	Skipped  State = "skipped"
)

type TabularSourceRow

type TabularSourceRow interface {
	Tabular() map[string]string
	Key() interface{}
	URL() string
}

Jump to

Keyboard shortcuts

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