Documentation ¶
Index ¶
- Variables
- func RawSchema() string
- func WriteDataset(path string, d Dataset) error
- func WriteStream(it Stream, w io.Writer) error
- func WriteZip(z *zip.Writer, d Dataset) error
- type Dataset
- type History
- type IODataset
- type Manifest
- func (mf Manifest) Diff(old Manifest) map[string]byte
- func (mf Manifest) First() (v *Version)
- func (mf Manifest) Get(name string) (Version, bool)
- func (mf Manifest) Len() int
- func (mf Manifest) Less(i, j int) bool
- func (mf Manifest) Set(v Version) Manifest
- func (mf Manifest) Sort() Manifest
- func (mf Manifest) Swap(i, j int)
- func (mf Manifest) Update(pr *dom.Project) (Manifest, error)
- func (mf Manifest) WriteTo(w io.Writer) (nn int64, err error)
- type Migration
- type Record
- type Stream
- type Vers
- type Version
- type Versioner
Constants ¶
This section is empty.
Variables ¶
var ErrNoChanges = fmt.Errorf("no changes")
var ErrNoHistory = fmt.Errorf("no history")
var NoVers = Vers{}
Functions ¶
func WriteDataset ¶
WriteDataset writes a dataset to path or returns an error. If the path ends in '.zip' a zip file is written, otherwise the dataset is written as individual gzipped file to the directory at path.
func WriteStream ¶
WriteStream writes stream to writer w or returns an error.
Types ¶
type Dataset ¶
type Dataset interface { // Vers returns the project version of this dataset. Vers() *Version // Keys returns all stream keys that are part of this data set. Keys() []string // Stream returns the stream with key or an error. Stream(key string) (Stream, error) // Close closes the dataset. Close() error }
Dataset is an abstraction over project data, be it a database, a test fixture or backup archive.
func ReadDataset ¶
ReadDataset returns a dataset with the manifest and data streams found at path or an error.
Path must either point to directory or a zip file containing individual files for the project version and data steams. The version file must be named 'version.json' and the individual data streams use the qualified model name with the '.json' extension for the format and optional a '.gz' extension, for gzipped files. The returned data streams are first read when iterated. We only allow the json format, because the files are usually machine written and read, and to make working with backups easier in other language.
type History ¶
type History interface { Path() string Curr() Record Last() Manifest Versions() []Version Manifest(vers string) (Manifest, error) Record(vers string) (Record, error) Commit(slug string) error }
History provides project records.
func ReadHistory ¶
ReadHistory returns the prepared project history based on a project path or an error.
The history folder path defaults to '$project/hist', but can changed in the project definition. The folder contains a link to, or copy of the last recorded manifest and record folders each containing a project definition and manifest file, encoded as optionally gzipped JSON streams. The record folders can also contain migration rules and scripts, to migration data to that version. The history folder acts as staging area for migrations for unrecorded project changes. Record folders can have any name starting with a 'v', the daql tool uses the padded version number and an optional record note that only acts as memory aid. The actual record version should always be read from the included manifest file.
type IODataset ¶
type IODataset interface { Dataset Open(key string) (io.ReadCloser, error) }
IODataset is a dataset that is based on file streams and provides access to those files.
type Manifest ¶
type Manifest []Version
Manifest is set of versions sorted by name. A Manifest usually contain exactly one project version as first element, due to the project name qualifier prefix.
func ReadManifest ¶
ReadManifest returns a manifest read from r or an error. Manifests are read as JSON stream of version objects.
func (Manifest) Diff ¶
Diff returns a map of all changed version names to a byte indicating the kind of change. The byte is the '+' for addition, '-' for deletion or '*' for modification.
func (Manifest) First ¶
First returns the first version of the manifest or nil. The first version is the project version, by the nature of the sort order, unless the manifest is unnaturally contains none or many project versions.
func (Manifest) Get ¶
Get returns the version for the qualified name or false if no version was found.
type Migration ¶
type Migration struct { ID int64 `json:"id"` Vers string `json:"vers"` Date time.Time `json:"date"` Note string `json:"note,omitempty"` }
Migration contains migration information of a data source.
type Record ¶
type Record struct { Path string `json:"path"` // record path relative to history folder *dom.Project Manifest `json:"manifest"` }
Record consists of a project definition and its manifest at one point in time. A record's path can be used to look up migration rules and scripts.
func ReadRecord ¶
ReadProject reads the current project's unrecorded definition and manifest or an error.
The returned record represent the current malleable project state, and may contain unrecorded changes and preliminary versions, not representing the eventually recorded version definition.
type Stream ¶
type Stream interface { // Scan returns the next value or an error, normal iteration must end with an eof error. Scan() (lit.Val, error) // Close closes the stream, possibly making it inoperable. Close() error }
Stream is an iterator for a possibly large sequence of object literal data.
This abstraction allows us to choose an appropriate implementation for any situation, without being forced to load all the data into memory all at once.
func NewFileStream ¶
NewFileStream creates and returns a new stream for the named reader f or an error.
func NewLitStream ¶
NewLitStream creates and returns a new stream for the idxr literal or an error.
func OpenFileStream ¶
OpenFileStream opens a file and returns a new stream or an error.
type Vers ¶
type Vers struct {
Major, Minor, Patch int
}
Vers represents a parsed version string with int fields for major, minor and patch versions.
type Version ¶
type Version struct { Name string `json:"name"` Vers string `json:"vers"` Date time.Time `json:"date,omitempty"` Minor string `json:"minor"` Patch string `json:"patch"` }
Version contains essential details for a node to derive a new version number.
The name is the node's qualified name, and date is an optional recording time. Vers is version string v1.23.4 for known versions or empty. The minor and patch are a lowercase hex sha256 hash strings of the node's details and its children.
func ReadVersion ¶
ReadVersion returns a version read from r or and error.
type Versioner ¶
type Versioner map[string]*entry
Versioner sets and returns node version details, usually based on the last recorded manifest.
func NewVersioner ¶
NewVersioner returns a new versioner based on the given manifest.