datastore

package
v0.0.0-...-9091db7 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2016 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package datastore manages the bolt data files and the reading and writing data to them

Index

Constants

This section is empty.

Variables

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

ErrNotFound is the error returned when a value cannot be found in the store for the given key

Functions

This section is empty.

Types

type Log

type Log struct {
	When    time.Time `json:"when,omitempty"`
	Version string    `json:"version,omitempty"`
	Stage   string    `json:"stage,omitempty"`
	Log     string    `json:"log,omitempty"`
}

Log is a version log entry for a project

type Release

type Release struct {
	When     time.Time `json:"when"`
	Version  string    `json:"version"`
	FileName string    `json:"fileName"`
	FileKey  TimeKey   `json:"fileKey"`
}

Release is a record of the fully built and ready to deploy release file

type Store

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

Store is a datastore for getting and setting data for a given ironsmith project run on top of a Bolt DB file

func Open

func Open(filename string) (*Store, error)

Open opens an existing datastore file, or creates a new one caller is responsible for closing the datastore

func (*Store) AddLog

func (ds *Store) AddLog(version, stage, entry string) error

AddLog adds a new log entry

func (*Store) AddRelease

func (ds *Store) AddRelease(version, fileName string, fileData []byte) error

AddRelease adds a new Release

func (*Store) Close

func (ds *Store) Close() error

Close closes the bolt datastore

func (*Store) LastRelease

func (ds *Store) LastRelease() (*Release, error)

LastRelease lists the last release for a project

func (*Store) LastVersion

func (ds *Store) LastVersion(stage string) (*Log, error)

LastVersion returns the last version in the log for the given stage. If stage is blank, then it returns the last of any stage

func (*Store) Release

func (ds *Store) Release(version string) (*Release, error)

Release gets the release record for a specific version

func (*Store) ReleaseFile

func (ds *Store) ReleaseFile(fileKey TimeKey) ([]byte, error)

ReleaseFile returns a specific file from a release for the given file key

func (*Store) Releases

func (ds *Store) Releases() ([]*Release, error)

Releases lists all the releases in a given project

func (*Store) StageLog

func (ds *Store) StageLog(version, stage string) (*Log, error)

StageLog returns the log entry for a given version + stage

func (*Store) TrimVersions

func (ds *Store) TrimVersions(maxVersions int) error

TrimVersions Removes versions from the datastore file until it reaches the maxVersions count

func (*Store) VersionLog

func (ds *Store) VersionLog(version string) ([]*Log, error)

VersionLog returns all the log entries for a given version

func (*Store) Versions

func (ds *Store) Versions() ([]*Log, error)

Versions lists the versions in a given project, including the last stage that version got to

type TimeKey

type TimeKey [16]byte

TimeKey is a unique time ordered key for use in the datastore A TimeKey is 32 bits random data + 96 bit UNIX timestamp (64bits seconds + 32 bit nanoseconds)

func NewTimeKey

func NewTimeKey() TimeKey

NewTimeKey returns a newly generated TimeKey based on the current time

func (TimeKey) Bytes

func (k TimeKey) Bytes() []byte

Bytes returns the a slice of the underlying bytes of a TimeKey

func (*TimeKey) MarshalJSON

func (k *TimeKey) MarshalJSON() ([]byte, error)

MarshalJSON implements JSON marshaler

func (TimeKey) String

func (k TimeKey) String() string

String returns the string representation of a timekey

func (TimeKey) Time

func (k TimeKey) Time() time.Time

Time returns the time portion of a timekey

func (TimeKey) UUID

func (k TimeKey) UUID() string

UUID returns the string representation of a TimeKey in Hex format separated by dashes similar to a UUID xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

func (*TimeKey) UnmarshalJSON

func (k *TimeKey) UnmarshalJSON(buf []byte) error

UnmarshalJSON implements JSON unmarshaler

Jump to

Keyboard shortcuts

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