Documentation ¶
Overview ¶
Package updates provides an utility to perform and aggregate model updates.
As input, it supports OVSDB Operations, RowUpdate or RowUpdate2 notations via the corresponding Add methods.
As output, it supports both OVSDB RowUpdate2 as well as model notation via the corresponding ForEach iterative methods.
Several updates can be added and will be merged with any previous updates even if they are for the same model. If several updates for the same model are aggregated, the user is responsible that the provided model to be updated matches the updated model of the previous update.
Index ¶
- func ProcessReferences(dbModel model.DatabaseModel, provider ReferenceProvider, updates ModelUpdates) (ModelUpdates, ModelUpdates, database.References, error)
- type DatabaseUpdate
- type ModelUpdates
- func (u *ModelUpdates) AddOperation(dbModel model.DatabaseModel, table, uuid string, current model.Model, ...) error
- func (u *ModelUpdates) AddRowUpdate(dbModel model.DatabaseModel, table, uuid string, current model.Model, ...) error
- func (u *ModelUpdates) AddRowUpdate2(dbModel model.DatabaseModel, table, uuid string, current model.Model, ...) error
- func (u ModelUpdates) ForEachModelUpdate(table string, do func(uuid string, old, new model.Model) error) error
- func (u ModelUpdates) ForEachRowUpdate(table string, do func(uuid string, row ovsdb.RowUpdate2) error) error
- func (u ModelUpdates) GetModel(table, uuid string) model.Model
- func (u ModelUpdates) GetRow(table, uuid string) *ovsdb.Row
- func (u ModelUpdates) GetUpdatedTables() []string
- func (u *ModelUpdates) Merge(dbModel model.DatabaseModel, new ModelUpdates) error
- type ReferenceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessReferences ¶
func ProcessReferences(dbModel model.DatabaseModel, provider ReferenceProvider, updates ModelUpdates) (ModelUpdates, ModelUpdates, database.References, error)
ProcessReferences tracks referential integrity for the provided set of updates. It returns an updated set of updates which includes additional updates and updated references as a result of the reference garbage collection described in RFC7047. These additional updates resulting from the reference garbage collection are also returned separately. Any constraint or referential integrity violation is returned as an error.
Types ¶
type DatabaseUpdate ¶
type DatabaseUpdate struct { ModelUpdates // contains filtered or unexported fields }
DatabaseUpdate bundles updates together with the updated reference information
func NewDatabaseUpdate ¶
func NewDatabaseUpdate(updates ModelUpdates, references database.References) DatabaseUpdate
func (DatabaseUpdate) ForReferenceUpdates ¶
func (u DatabaseUpdate) ForReferenceUpdates(do func(references database.References) error) error
type ModelUpdates ¶
type ModelUpdates struct {
// contains filtered or unexported fields
}
ModelUpdates contains updates indexed by table and uuid
func (*ModelUpdates) AddOperation ¶
func (u *ModelUpdates) AddOperation(dbModel model.DatabaseModel, table, uuid string, current model.Model, op *ovsdb.Operation) error
AddOperation adds an update for a model from a OVSDB Operation. If several updates for the same model are aggregated, the user is responsible that the provided model to be updated matches the updated model of the previous update.
func (*ModelUpdates) AddRowUpdate ¶
func (u *ModelUpdates) AddRowUpdate(dbModel model.DatabaseModel, table, uuid string, current model.Model, ru ovsdb.RowUpdate) error
AddRowUpdate adds an update for a model from a OVSDB RowUpdate. If several updates for the same model are aggregated, the user is responsible that the provided model to be updated matches the updated model of the previous update.
func (*ModelUpdates) AddRowUpdate2 ¶
func (u *ModelUpdates) AddRowUpdate2(dbModel model.DatabaseModel, table, uuid string, current model.Model, ru2 ovsdb.RowUpdate2) error
AddRowUpdate2 adds an update for a model from a OVSDB RowUpdate2. If several updates for the same model are aggregated, the user is responsible that the provided model to be updated matches the updated model of the previous update.
func (ModelUpdates) ForEachModelUpdate ¶
func (u ModelUpdates) ForEachModelUpdate(table string, do func(uuid string, old, new model.Model) error) error
ForEachModelUpdate processes each row update of a given table in model notation
func (ModelUpdates) ForEachRowUpdate ¶
func (u ModelUpdates) ForEachRowUpdate(table string, do func(uuid string, row ovsdb.RowUpdate2) error) error
ForEachRowUpdate processes each row update of a given table in OVSDB RowUpdate2 notation
func (ModelUpdates) GetModel ¶
func (u ModelUpdates) GetModel(table, uuid string) model.Model
GetModel returns the last known state of the requested model. If the model is unknown or has been deleted, returns nil.
func (ModelUpdates) GetRow ¶
func (u ModelUpdates) GetRow(table, uuid string) *ovsdb.Row
GetRow returns the last known state of the requested row. If the row is unknown or has been deleted, returns nil.
func (ModelUpdates) GetUpdatedTables ¶
func (u ModelUpdates) GetUpdatedTables() []string
GetUpdatedTables returns the tables that have updates
func (*ModelUpdates) Merge ¶
func (u *ModelUpdates) Merge(dbModel model.DatabaseModel, new ModelUpdates) error
Merge a set of updates with an earlier set of updates
type ReferenceProvider ¶
type ReferenceProvider interface { // GetReferences provides the references to the provided row GetReferences(database, table, uuid string) (database.References, error) // Get provides the corresponding model Get(database, table string, uuid string) (model.Model, error) }
ReferenceProvider should be implemented by a database that tracks references