model

package
v0.0.0-...-f0bc3ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneInto

func CloneInto(src, dst Model)

CloneInto deep copies a model into another one

func Equal

func Equal(l, r Model) bool

Types

type ClientDBModel

type ClientDBModel struct {
	// contains filtered or unexported fields
}

ClientDBModel contains the client information needed to build a DatabaseModel

func NewClientDBModel

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

func (db ClientDBModel) Indexes(table string) []ClientIndex

Indexes returns the client indexes for a model

func (ClientDBModel) Name

func (db ClientDBModel) Name() string

Name returns the database name

func (*ClientDBModel) SetIndexes

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

type ClientIndex struct {
	Columns []ColumnKey
}

ClientIndex defines a client index by a set of columns

type CloneableModel

type CloneableModel interface {
	CloneModel() Model
	CloneModelInto(Model)
}

type ColumnKey

type ColumnKey struct {
	Column string
	Key    interface{}
}

ColumnKey addresses a column and optionally a key within a column

type ComparableModel

type ComparableModel interface {
	EqualsModel(Model) bool
}

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

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

func NewDatabaseModel(schema ovsdb.DatabaseSchema, client ClientDBModel) (DatabaseModel, []error)

NewDatabaseModel returns a new DatabaseModel

func NewPartialDatabaseModel

func NewPartialDatabaseModel(client ClientDBModel) DatabaseModel

NewPartialDatabaseModel returns a DatabaseModel what does not have a schema yet

func (DatabaseModel) Client

func (db DatabaseModel) Client() ClientDBModel

Client returns the DatabaseModel's client dbModel

func (DatabaseModel) FindTable

func (db DatabaseModel) FindTable(mType reflect.Type) string

FindTable returns the string associated with a reflect.Type or ""

func (DatabaseModel) NewModel

func (db DatabaseModel) NewModel(table string) (Model, error)

NewModel returns a new instance of a model from a specific string

func (DatabaseModel) NewModelInfo

func (db DatabaseModel) NewModelInfo(obj interface{}) (*mapper.Info, error)

NewModelInfo returns a mapper.Info object based on a provided model

func (DatabaseModel) Types

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

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 Clone

func Clone(a Model) Model

Clone creates a deep copy of a model

func CreateModel

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL