store

package
v0.0.0-...-0452748 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// S3 backend options
	S3 struct {
		Bucket string `long:"bucket" env:"S3_BUCKET" description:"name of the bucket"`
		Key    string `long:"key" default:"state.json" env:"S3_KEY" description:"path to the key"`
	} `group:"store.s3" namespace:"s3"`

	// Postgres backend options
	Postgres struct {
		Datasource string `long:"datasource" env:"PG_DATASOURCE" description:"postgresql datasource (see database/sql)"`
	} `group:"store.postgres" namespace:"pg"`

	// File backend options. This is the default if nothing else is provided
	File struct {
		Path string `long:"path" default:".sauron" env:"STORE_FILE_PATH" description:"path of the state file"`
	} `group:"store.file" namespace:"file"`
}

Options contains the parameters necessary to configure a concrete Store implementation

type RepoState

type RepoState struct {
	model.Update

	LastChecked time.Time `db:"last_checked"`
}

RepoState records the last known state of a given repository

type State

type State map[WatchKey]RepoState

State represents the state tracked by Sauron

type Store

type Store interface {
	GetLastUpdate(key WatchKey) (model.Update, error)
	RecordUpdate(key WatchKey, update model.Update) error
	SetLastChecked(key WatchKey) error
}

Store is the storage layer interface for Sauron

func New

func New(opts Options) Store

New returns a new concrete Store implementation depending on which options are set. If none, a basic file-backed implementation is returned

func NewFile

func NewFile(path string) Store

NewFile instantiates a new concrete Store backed by a local file.

func NewPostgres

func NewPostgres(dataSource string) Store

NewPostgres instantiates a new concrete Store. NewPostgres panics if the dataSource is invalid or if the schema cannot be initialized.

func NewS3

func NewS3(bucket, key string) Store

NewS3 instantiates a new concrete Store backed by an amazon S3 object.

type WatchKey

type WatchKey struct {
	Repository model.Repository

	Branch string

	Path string
}

WatchKey is used to retrieve a RepoState from the global state

func Key

func Key(opts model.WatchOptions) WatchKey

Key creates a new WatchKey from a WatchOptions value

func (WatchKey) MarshalText

func (k WatchKey) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaller interface

func (*WatchKey) UnmarshalText

func (k *WatchKey) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextUnmarshaller interface

Jump to

Keyboard shortcuts

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