Documentation ¶
Overview ¶
NanoNanostate implementation. Nanostate example:
---------------------------------------------- id: some-Nanostate descr: This describes what this Nanostate is for.
state:
maintain-database: - sshrunner: - stop-db: systemctl stop postgresql.service - backup-db: pg-backup /var/lib/pgsql/data /opt/backups/ - start-db: systemctl start postgresql.service - somemodule: keyparam: valueparam keyparam2: valueparam2 keyparam3: valueparam3 some-other-group: - sshrunner: - uptime: uptime - id : cat /etc/machine-id
----------------------------------------------
In the example above, three fields are required:
- id This an ID of the Nanostate. It is used for the reporting at the end.
- descr: Description of the Nanostate. Also reporting.
- state: This is the entire tree of the Nanostate structure. It has twofold tree: a group IDs with a list of modules and the params or commands below.
Currently only one module is implemented: sshrunner, which performs a series of synchronous commands in the order they were placed for orchestration purposes.
In the nanoNanostate groups are asynchronous, but the commands inside the groups are synchronous.
Index ¶
- type NanoStateFunctionsMeta
- type NanoStateIndex
- func (nsf *NanoStateIndex) AddStateRoot(pth string) *NanoStateIndex
- func (nsf *NanoStateIndex) AddStateRoots(pth ...string) *NanoStateIndex
- func (nsf *NanoStateIndex) GetStateByFileName(name string) (*NanoStateMeta, error)
- func (nsf *NanoStateIndex) GetStateById(id string) (*NanoStateMeta, error)
- func (nsf *NanoStateIndex) GetStateRoots() []string
- func (nsf *NanoStateIndex) Index() *NanoStateIndex
- type NanoStateMeta
- type Nanostate
- type StateCompiler
- type StateGroup
- type StateModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NanoStateFunctionsMeta ¶
type NanoStateIndex ¶
type NanoStateIndex struct {
// contains filtered or unexported fields
}
func NewNanoStateIndex ¶
func NewNanoStateIndex() *NanoStateIndex
func (*NanoStateIndex) AddStateRoot ¶
func (nsf *NanoStateIndex) AddStateRoot(pth string) *NanoStateIndex
AddStateRoot is used to chain-add another state root
func (*NanoStateIndex) AddStateRoots ¶
func (nsf *NanoStateIndex) AddStateRoots(pth ...string) *NanoStateIndex
AddStateRoots is used to chain-add another state roots (array)
func (*NanoStateIndex) GetStateByFileName ¶
func (nsf *NanoStateIndex) GetStateByFileName(name string) (*NanoStateMeta, error)
func (*NanoStateIndex) GetStateById ¶
func (nsf *NanoStateIndex) GetStateById(id string) (*NanoStateMeta, error)
func (*NanoStateIndex) GetStateRoots ¶
func (nsf *NanoStateIndex) GetStateRoots() []string
GetStateRoots where states and collections are located
func (*NanoStateIndex) Index ¶
func (nsf *NanoStateIndex) Index() *NanoStateIndex
Index all the files in the all roots
type NanoStateMeta ¶
type Nanostate ¶
type Nanostate struct { Id string Descr string Groups []*StateGroup GroupIndex []string }
func NewNanostate ¶
func NewNanostate() *Nanostate
func (*Nanostate) Load ¶
func (pb *Nanostate) Load(tree *nanocms_compiler.OTree) error
Load Nanostate tree, which is already compiled statically and vaildated.
func (*Nanostate) OrderedGroups ¶
func (pb *Nanostate) OrderedGroups() []*StateGroup
type StateCompiler ¶
type StateCompiler struct {
// contains filtered or unexported fields
}
func NewStateCompiler ¶
func NewStateCompiler() *StateCompiler
func (*StateCompiler) Compile ¶
func (nst *StateCompiler) Compile(indexPath string) (int, error)
Compile state tree starting from the entry state as a resolvable path.
func (*StateCompiler) GetState ¶
func (nst *StateCompiler) GetState() *Nanostate
GetState returns an instance of the compiled state
func (*StateCompiler) GetStateIndex ¶
func (nst *StateCompiler) GetStateIndex() *NanoStateIndex
GetStateIndex returns an instance of the state index.
func (*StateCompiler) Index ¶
func (nst *StateCompiler) Index(roots ...string) *StateCompiler
Index state roots
type StateGroup ¶
type StateGroup struct { Id string Group []*StateModule }