Documentation ¶
Index ¶
- func Get(st *state.State, account, confdbName, viewName string, fields []string) (interface{}, error)
- func GetTransactionToModify(ctx *hookstate.Context, st *state.State, view *confdb.View) (*Transaction, CommitTxFunc, error)
- func GetViaView(bag confdb.DataBag, view *confdb.View, fields []string) (interface{}, error)
- func GetView(st *state.State, account, confdbName, viewName string) (*confdb.View, error)
- func IsConfdbHook(ctx *hookstate.Context) bool
- func Set(st *state.State, account, confdbName, viewName string, ...) error
- func SetViaView(bag confdb.DataBag, view *confdb.View, requests map[string]interface{}) error
- type CommitTxFunc
- type ConfdbManager
- type Transaction
- func (t *Transaction) Abort(abortingSnap, reason string)
- func (t *Transaction) AbortInfo() (snap, reason string)
- func (t *Transaction) AlteredPaths() []string
- func (t *Transaction) Clear(st *state.State) error
- func (t *Transaction) Commit(st *state.State, schema confdb.Schema) error
- func (t *Transaction) Data() ([]byte, error)
- func (t *Transaction) Get(path string) (interface{}, error)
- func (t *Transaction) MarshalJSON() ([]byte, error)
- func (t *Transaction) Pristine() confdb.DataBag
- func (t *Transaction) Set(path string, value interface{}) error
- func (t *Transaction) UnmarshalJSON(data []byte) error
- func (t *Transaction) Unset(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Get ¶
func Get(st *state.State, account, confdbName, viewName string, fields []string) (interface{}, error)
Get finds the view identified by the account, confdb and view names and uses it to get the values for the specified fields. The results are returned in a map of fields to their values, unless there are no fields in which case case all views are returned.
func GetTransactionToModify ¶
func GetTransactionToModify(ctx *hookstate.Context, st *state.State, view *confdb.View) (*Transaction, CommitTxFunc, error)
GetTransactionToModify retrieves or creates a transaction to change the view's confdb. The state must be locked by the caller. Takes a hookstate.Context if invoked in a hook. If a new transaction was created, also returns a CommitTxFunc to be called to start committing (which in turn returns a change ID and a wait channel that will be closed on the commit is done). If a transaction already existed, changes to it will be saved on ctx.Done().
func GetViaView ¶
GetViaView uses the view to get values for the fields from the databag in the transaction.
func IsConfdbHook ¶
IsConfdbHook returns whether the hook context belongs to a confdb hook.
Types ¶
type CommitTxFunc ¶
type ConfdbManager ¶
type ConfdbManager struct{}
func Manager ¶
func Manager(st *state.State, hookMgr *hookstate.HookManager, runner *state.TaskRunner) *ConfdbManager
func (*ConfdbManager) Ensure ¶
func (m *ConfdbManager) Ensure() error
type Transaction ¶
type Transaction struct { ConfdbAccount string ConfdbName string // contains filtered or unexported fields }
Transaction performs read and writes to a databag in an atomic way.
func GetStoredTransaction ¶
func GetStoredTransaction(t *state.Task) (tx *Transaction, saveTxChanges func(), err error)
GetStoredTransaction returns the transaction associated with the task (even if indirectly) and a callback to persist changes made to it.
func NewTransaction ¶
func NewTransaction(st *state.State, account, confdbName string) (*Transaction, error)
NewTransaction takes a getter and setter to read and write the databag.
func (*Transaction) Abort ¶
func (t *Transaction) Abort(abortingSnap, reason string)
Abort prevents any further writes or reads to the transaction. It takes a snap and reason that can be used to surface information to the user.
func (*Transaction) AbortInfo ¶
func (t *Transaction) AbortInfo() (snap, reason string)
func (*Transaction) AlteredPaths ¶
func (t *Transaction) AlteredPaths() []string
func (*Transaction) Commit ¶
Commit applies the previous writes and validates the final databag. If any error occurs, the original databag is kept.
func (*Transaction) Data ¶
func (t *Transaction) Data() ([]byte, error)
Data returns the transaction's committed data.
func (*Transaction) Get ¶
func (t *Transaction) Get(path string) (interface{}, error)
Get reads a value from the transaction's databag including uncommitted changes.
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
func (*Transaction) Pristine ¶
func (t *Transaction) Pristine() confdb.DataBag
func (*Transaction) Set ¶
func (t *Transaction) Set(path string, value interface{}) error
Set sets a value in the transaction's databag. The change isn't persisted until Commit returns without errors.
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(data []byte) error
func (*Transaction) Unset ¶
func (t *Transaction) Unset(path string) error
Unset unsets a value in the transaction's databag. The change isn't persisted until Commit returns without errors.