Documentation ¶
Index ¶
- Variables
- type DepGraph
- type DepSet
- type FS
- type OSFS
- type Repo
- type VarSolver
- type Variables
- func (vars Variables) AddParent(srv, parent string) error
- func (vars Variables) Get(service, key string) (string, error)
- func (vars *Variables) GobDecode(data []byte) error
- func (vars Variables) GobEncode() ([]byte, error)
- func (vars Variables) Insert(srv, key string, val service.VarValue) error
- func (vars Variables) InsertMany(srv string, values map[string]service.VarValue) error
- func (vars Variables) Length() int
- func (vars Variables) Parents(srv string) ([]string, error)
- func (vars Variables) RegisterSolver(kind service.VarKind, solv VarSolver)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoService is returned when no Service could be found. ErrNoService = errors.New("service not found") // ErrNoVariable is returned when no variable name could be found. ErrNoVariable = errors.New("variable not found") )
Functions ¶
This section is empty.
Types ¶
type DepGraph ¶
type DepGraph struct {
// contains filtered or unexported fields
}
DepGraph is the dependency graph of a service, akin to a family tree. Levels contain dependencies of dependencies: level 0 contains dependencies of the main service, while level 1 contains dependencies of all services in level 1, an so on. Levels are 0-indexed.
func NewDepGraph ¶
NewDepGraph returns an empty DepGraph with an initial capacity.
type DepSet ¶
DepSet is a unique set of services.
type FS ¶
type FS struct {
// contains filtered or unexported fields
}
FS is a repository based on a filesystem.
func NewFSVariant ¶
NewFSVariant creates a new FS repository from an existing filesystem. The new FS repository will return services for the given system variant.
func (FS) AllServices ¶
AllServices returns all services in the filesystem.
func (FS) DataDir ¶
DataDir returns the data directory path for a hypothetical service. There is no guarantee that the path exists.
func (FS) LinkDir ¶
DataDir returns the link directory path for a hypothetical service. There is no guarantee that the path exists.
func (FS) ResolveDeps ¶
ResolveDeps resolves the dependency graph for srv. If srv has no dependencies, the dependency graph will be empty.
type OSFS ¶
OSFS circumvents the inability to check whether fs.FS is a real operating system path. FSRepo will use OSFS to discriminate a real OS path from a network, or a testing, file system.
Ideally, Go should provide the inverse operation of os.DirFS().
type Repo ¶
type Repo interface { // DataDir returns the data directory path of a service. DataDir(srvName string) (string, error) // Link returns the symlink directory path of a service. LinkDir(srvName string) (string, error) // ResolveDeps creates the dependency tree of a service. ResolveDeps(srv *service.Service) (DepGraph, error) }
Repo is capable of fetching services from a source.
type VarSolver ¶
type VarSolver interface { // Value resolves the intermediate value // of varName or returns an error. Value(varName string) (varValue string, err error) }
VarSolver resolves the intermediate value of variables.
type Variables ¶
type Variables struct { // Common is an optional collection of variables that services // might have in common. It is initially nil. Common map[string]string // contains filtered or unexported fields }
Variables resolves and caches services' variables.
func NewVariables ¶
func NewVariables() Variables
func (Variables) AddParent ¶
AddParent adds parent to the parents of srv. That hints the two services are tied together and it may be useful to Get parent's variables as well when Getting srv's variables. AddParent returns ErrNoService if srv or parent does not exist.
func (Variables) Get ¶
Get returns the value of a Service's variable, previously cached via Insert. If srv does not exist, ErrNoService is returned. If key does not exist, ErrNoVariable is returned.
func (Variables) Insert ¶
Insert saves value for a service named srv under key. If the value is not clear text, it is resolved immediately and then cached. If key is already present for srv, Insert is no-op.
func (Variables) InsertMany ¶
InsertMany is a convenience method to Insert multiple values.