base

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: GPL-3.0 Imports: 30 Imported by: 1

Documentation

Overview

Package base defines business that operates on local data. it's main job is to composing APIs from the lower half of our tech stack, providing uniform functions for higher up packages, mainly p2p and actions. p2p and actions should use base as the only way of operate on the local repo Here's some ascii art to clarify the stack:

┌───────────────┐ ┌───────────────┐
│      cmd      │ │     api       │
└───────────────┘ └───────────────┘
┌─────────────────────────────────┐
│               lib               │
└─────────────────────────────────┘
┌─────────────────────────────────┐
│             actions             │
└─────────────────────────────────┘
┌───────────────────────┐
│          p2p          │
└───────────────────────┘
┌─────────────────────────────────┐
│              base               │  <-- you are here
└─────────────────────────────────┘
┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐
│ repo │ │ dsfs │ │ cafs │ │ ...  │
└──────┘ └──────┘ └──────┘ └──────┘

There are packages omitted from this diagram, but these are the vitals. base functions mainly work with repo.Repo instances, using repo interface methods and related packages to do their work. This is part of a larger pattern of having actions rely on lower level interfaces wherever possible to enhance configurability

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplate = `` /* 249-byte string literal not displayed */

DefaultTemplate is the template that render will fall back to should no template be available

Functions

func ApplyPath

func ApplyPath(ds *dataset.Dataset, path string) (interface{}, error)

ApplyPath gets a dataset value by applying a case.Sensitve.dot.separated.path ApplyPath cannot select file fields

func CloseDataset added in v0.7.0

func CloseDataset(ds *dataset.Dataset) (err error)

CloseDataset ensures all open dataset files are closed

func ConvertBodyFile added in v0.7.2

func ConvertBodyFile(file qfs.File, in, out *dataset.Structure, limit, offset int, all bool) (data []byte, err error)

ConvertBodyFile takes an input file & structure, and converts a specified selection to the structure specified by out

func ConvertBodyFormat added in v0.6.1

func ConvertBodyFormat(bodyFile qfs.File, fromSt, toSt *dataset.Structure) (qfs.File, error)

ConvertBodyFormat rewrites a body from a source format to a destination format.

func CreateDataset

func CreateDataset(r repo.Repo, streams ioes.IOStreams, ds, dsPrev *dataset.Dataset, dryRun, pin, force, shouldRender bool) (ref repo.DatasetRef, err error)

CreateDataset uses dsfs to add a dataset to a repo's store, updating all references within the repo if successful. CreateDataset is a lower-level component of github.com/qri-io/qri/actions.CreateDataset

func DatasetBodyFile added in v0.7.0

func DatasetBodyFile(store cafs.Filestore, ds *dataset.Dataset) (qfs.File, error)

DatasetBodyFile creates a streaming data file from a Dataset using the following precedence: * ds.BodyBytes not being nil (requires ds.Structure.Format be set to know data format) * ds.BodyPath being a url * ds.BodyPath being a path on the local filesystem TODO - consider moving this func to some other package. maybe actions?

func DatasetLog

func DatasetLog(r repo.Repo, ref repo.DatasetRef, limit, offset int, loadDatasets bool) (rlog []repo.DatasetRef, err error)

DatasetLog fetches the history of changes to a dataset, if loadDatasets is true, dataset information will be populated

func FetchDataset

func FetchDataset(r repo.Repo, ref *repo.DatasetRef, pin, load bool) (err error)

FetchDataset grabs a dataset from a remote source

func InLocalNamespace

func InLocalNamespace(r repo.Repo, ref *repo.DatasetRef) bool

InLocalNamespace checks if a dataset ref is local, assumes the reference is already canonicalized

func InferValues

func InferValues(pro *profile.Profile, ds *dataset.Dataset) error

InferValues populates any missing fields that must exist to create a snapshot

func InlineJSONBody added in v0.7.2

func InlineJSONBody(ds *dataset.Dataset) error

InlineJSONBody reads the contents dataset.BodyFile() into a json.RawMessage, assigning the result to dataset.Body

func ListDatasets

func ListDatasets(r repo.Repo, term string, limit, offset int, RPC, publishedOnly, showVersions bool) (res []repo.DatasetRef, err error)

ListDatasets lists datasets from a repo

func LoadRevs

func LoadRevs(r repo.Repo, ref repo.DatasetRef, revs []*rev.Rev) (res *dataset.Dataset, err error)

LoadRevs grabs a component of a dataset that exists <n>th generation ancestor of the referenced version, where presence of a component in a previous snapshot constitutes ancestry

func MaybeAddDefaultViz added in v0.8.0

func MaybeAddDefaultViz(ds *dataset.Dataset)

MaybeAddDefaultViz sets a dataset viz component and template if none exists

func NewDAGInfo added in v0.7.3

func NewDAGInfo(ctx context.Context, store cafs.Filestore, ng ipld.NodeGetter, path, label string) (*dag.Info, error)

NewDAGInfo generates a DAGInfo for a given node. If a label is provided, it gnenerates a sub-DAGInfo at that

func NewManifest added in v0.6.1

func NewManifest(ctx context.Context, ng ipld.NodeGetter, path string) (*dag.Manifest, error)

NewManifest generates a manifest for a given node

func OpenDataset added in v0.7.0

func OpenDataset(fsys qfs.Filesystem, ds *dataset.Dataset) (err error)

OpenDataset prepares a dataset for use, checking each component for populated Path or Byte suffixed fields, consuming those fields to set File handlers that are ready for reading

func PinDataset

func PinDataset(r repo.Repo, ref repo.DatasetRef) error

PinDataset marks a dataset for retention in a store

func PrepareDatasetSave

func PrepareDatasetSave(r repo.Repo, peername, name string) (prev, mutable *dataset.Dataset, prevPath string, err error)

PrepareDatasetSave prepares a set of changes for submission to SaveDataset prev is the previous dataset, if it exists body is the previous dataset body, if it exists mutable is the previous dataset, but without the commit and transform, making it sutable for mutation/combination with any potential changes requested by the user we do not error if the dataset is not found in the repo, instead we return all empty values TODO (b5): input parameters here assume the store can properly resolve the previous dataset path through canonicalization (looking the name up in the repo). The value given by the input dataset document may differ, and we should probably respect that value if it does

func ReadDataset

func ReadDataset(r repo.Repo, ref *repo.DatasetRef) (err error)

ReadDataset grabs a dataset from the store

func ReadDatasetPath added in v0.7.0

func ReadDatasetPath(r repo.Repo, path string) (ds *dataset.Dataset, err error)

ReadDatasetPath takes a path string, parses, canonicalizes, loads a dataset pointer, and opens the file The medium-term goal here is to obfuscate use of repo.DatasetRef, which we're hoping to deprecate

func ReadEntries added in v0.7.1

func ReadEntries(reader dsio.EntryReader) (interface{}, error)

ReadEntries reads entries and returns them as a native go array or map

func Render

func Render(r repo.Repo, ref repo.DatasetRef, tmplData []byte) ([]byte, error)

Render executes a template for a dataset, returning a slice of HTML

func Select

func Select(r repo.Repo, ref repo.DatasetRef, path string) (interface{}, error)

Select loads a dataset value specified by case.Sensitve.dot.separated.paths

func SetPublishStatus

func SetPublishStatus(r repo.Repo, ref *repo.DatasetRef, published bool) error

SetPublishStatus updates the Published field of a dataset ref

func UnpinDataset

func UnpinDataset(r repo.Repo, ref repo.DatasetRef) error

UnpinDataset unmarks a dataset for retention in a store

func ValidateDataset

func ValidateDataset(ds *dataset.Dataset) (err error)

ValidateDataset checks that a dataset is semantically valid

Types

type LogDiffResult

type LogDiffResult struct {
	Head        repo.DatasetRef
	Add, Remove []repo.DatasetRef
}

LogDiffResult is the result of comparing a set of references

func LogDiff

func LogDiff(r repo.Repo, a []repo.DatasetRef) (ldr LogDiffResult, err error)

LogDiff determines the difference between an input slice of references

Directories

Path Synopsis
Package fill assigns arbitrary values to struct fields using reflection.
Package fill assigns arbitrary values to struct fields using reflection.

Jump to

Keyboard shortcuts

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