Documentation ¶
Index ¶
- func CloneInto(src, dst Model)
- func Equal(l, r Model) bool
- type ClientDBModel
- type ClientIndex
- type CloneableModel
- type ColumnKey
- type ComparableModel
- type Condition
- type DatabaseModel
- func (db DatabaseModel) Client() ClientDBModel
- func (db DatabaseModel) FindTable(mType reflect.Type) string
- func (db DatabaseModel) NewModel(table string) (Model, error)
- func (db DatabaseModel) NewModelInfo(obj interface{}) (*mapper.Info, error)
- func (db DatabaseModel) Types() map[string]reflect.Type
- func (db DatabaseModel) Valid() bool
- type Model
- type Mutation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientDBModel ¶ added in v0.7.0
type ClientDBModel struct {
// contains filtered or unexported fields
}
ClientDBModel contains the client information needed to build a DatabaseModel
func NewClientDBModel ¶ added in v0.7.0
func NewClientDBModel(name string, models map[string]Model) (ClientDBModel, error)
NewClientDBModel constructs a ClientDBModel based on a database name and dictionary of models indexed by table name
func (ClientDBModel) Indexes ¶ added in v0.7.0
func (db ClientDBModel) Indexes(table string) []ClientIndex
Indexes returns the client indexes for a model
func (ClientDBModel) Name ¶ added in v0.7.0
func (db ClientDBModel) Name() string
Name returns the database name
func (*ClientDBModel) SetIndexes ¶ added in v0.7.0
func (db *ClientDBModel) SetIndexes(indexes map[string][]ClientIndex)
SetIndexes sets the client indexes. Client indexes are optional, similar to schema indexes and are only tracked in the specific client instances that are provided with this client model. A client index may point to multiple models as uniqueness is not enforced. They are defined per table and multiple indexes can be defined for a table. Each index consists of a set of columns. If the column is a map, specific keys of that map can be addressed for the index.
type ClientIndex ¶ added in v0.7.0
type ClientIndex struct {
Columns []ColumnKey
}
ClientIndex defines a client index by a set of columns
type CloneableModel ¶ added in v0.7.0
type ColumnKey ¶ added in v0.7.0
type ColumnKey struct { Column string Key interface{} }
ColumnKey addresses a column and optionally a key within a column
type ComparableModel ¶ added in v0.7.0
type Condition ¶
type Condition struct { // Pointer to the field of the model where the operation applies Field interface{} // Condition function Function ovsdb.ConditionFunction // Value to use in the condition Value interface{} }
Condition is a model-based representation of an OVSDB Condition
type DatabaseModel ¶ added in v0.7.0
type DatabaseModel struct { Schema ovsdb.DatabaseSchema Mapper mapper.Mapper // contains filtered or unexported fields }
A DatabaseModel represents libovsdb's metadata about the database. It's the result of combining the client's ClientDBModel and the server's Schema
func NewDatabaseModel ¶ added in v0.7.0
func NewDatabaseModel(schema ovsdb.DatabaseSchema, client ClientDBModel) (DatabaseModel, []error)
NewDatabaseModel returns a new DatabaseModel
func NewPartialDatabaseModel ¶ added in v0.7.0
func NewPartialDatabaseModel(client ClientDBModel) DatabaseModel
NewPartialDatabaseModel returns a DatabaseModel what does not have a schema yet
func (DatabaseModel) Client ¶ added in v0.7.0
func (db DatabaseModel) Client() ClientDBModel
Client returns the DatabaseModel's client dbModel
func (DatabaseModel) FindTable ¶ added in v0.7.0
func (db DatabaseModel) FindTable(mType reflect.Type) string
FindTable returns the string associated with a reflect.Type or ""
func (DatabaseModel) NewModel ¶ added in v0.7.0
func (db DatabaseModel) NewModel(table string) (Model, error)
NewModel returns a new instance of a model from a specific string
func (DatabaseModel) NewModelInfo ¶ added in v0.7.0
func (db DatabaseModel) NewModelInfo(obj interface{}) (*mapper.Info, error)
NewModelInfo returns a mapper.Info object based on a provided model
func (DatabaseModel) Types ¶ added in v0.7.0
func (db DatabaseModel) Types() map[string]reflect.Type
Types returns the DatabaseModel Types the DatabaseModel types is a map of reflect.Types indexed by string The reflect.Type is a pointer to a struct that contains 'ovs' tags as described above. Such pointer to struct also implements the Model interface
func (DatabaseModel) Valid ¶ added in v0.7.0
func (db DatabaseModel) Valid() bool
Valid returns whether the DatabaseModel is fully functional
type Model ¶
type Model interface{}
A Model is the base interface used to build Database Models. It is used to express how data from a specific Database Table shall be translated into structs A Model is a struct with at least one (most likely more) field tagged with the 'ovs' tag The value of 'ovs' field must be a valid column name in the OVS Database A field associated with the "_uuid" column mandatory. The rest of the columns are optional The struct may also have non-tagged fields (which will be ignored by the API calls) The Model interface must be implemented by the pointer to such type Example:
type MyLogicalRouter struct { UUID string `ovsdb:"_uuid"` Name string `ovsdb:"name"` ExternalIDs map[string]string `ovsdb:"external_ids"` LoadBalancers []string `ovsdb:"load_balancer"` }
func CreateModel ¶ added in v0.7.0
func CreateModel(dbModel DatabaseModel, tableName string, row *ovsdb.Row, uuid string) (Model, error)
CreateModel creates a new Model instance based on an OVSDB Row information
type Mutation ¶
type Mutation struct { // Pointer to the field of the model that shall be mutated Field interface{} // String representing the mutator (as per RFC7047) Mutator ovsdb.Mutator // Value to use in the mutation Value interface{} }
Mutation is a model-based representation of an OVSDB Mutation