Documentation ¶
Index ¶
- Constants
- Variables
- func IsDefaultValue(column *ColumnSchema, nativeElem interface{}) bool
- func NativeToOvs(column *ColumnSchema, rawElem interface{}) (interface{}, error)
- func NativeToOvsAtomic(basicType string, nativeElem interface{}) (interface{}, error)
- func NativeType(column *ColumnSchema) reflect.Type
- func NativeTypeFromAtomic(basicType string) reflect.Type
- func NewCancelArgs(id interface{}) []interface{}
- func NewEchoArgs() []interface{}
- func NewErrWrongType(from, expected string, got interface{}) error
- func NewGetSchemaArgs(schema string) []interface{}
- func NewLockArgs(id interface{}) []interface{}
- func NewMonitorArgs(database string, value interface{}, requests map[string]MonitorRequest) []interface{}
- func NewMonitorCancelArgs(value interface{}) []interface{}
- func NewTransactArgs(database string, operations ...Operation) []interface{}
- func OvsToNative(column *ColumnSchema, ovsElem interface{}) (interface{}, error)
- func OvsToNativeAtomic(basicType string, ovsElem interface{}) (interface{}, error)
- func ValidateCondition(column *ColumnSchema, function ConditionFunction, nativeValue interface{}) error
- func ValidateMutation(column *ColumnSchema, mutator Mutator, value interface{}) error
- type Aborted
- type BaseType
- func (b BaseType) MarshalJSON() ([]byte, error)
- func (b *BaseType) MaxInteger() (int, error)
- func (b *BaseType) MaxLength() (int, error)
- func (b *BaseType) MaxReal() (float64, error)
- func (b *BaseType) MinInteger() (int, error)
- func (b *BaseType) MinLength() (int, error)
- func (b *BaseType) MinReal() (float64, error)
- func (b *BaseType) RefTable() (string, error)
- func (b *BaseType) RefType() (RefType, error)
- func (b *BaseType) UnmarshalJSON(data []byte) error
- type ColumnSchema
- type ColumnType
- type Condition
- type ConditionFunction
- type ConstraintViolation
- type DatabaseSchema
- type DomainError
- type DuplicateUUIDName
- type ErrWrongType
- type Error
- type ExtendedType
- type IOError
- type MonitorRequest
- type MonitorRequests
- type MonitorSelect
- type Mutation
- type Mutator
- type NotOwner
- type NotSupported
- type NotificationHandler
- type Operation
- type OperationError
- type OperationResult
- type OvsMap
- type OvsSet
- type RangeError
- type RefType
- type ReferentialIntegrityViolation
- type ResourcesExhausted
- type Row
- type RowUpdate
- type TableSchema
- type TableUpdate
- type TableUpdates
- type TimedOut
- type TransactResponse
- type UUID
Constants ¶
const ( // OperationInsert is an insert operation OperationInsert = "insert" // OperationSelect is a select operation OperationSelect = "select" // OperationUpdate is an update operation OperationUpdate = "update" // OperationMutate is a mutate operation OperationMutate = "mutate" // OperationDelete is a delete operation OperationDelete = "delete" // OperationWait is a wait operation OperationWait = "wait" // OperationCommit is a commit operation OperationCommit = "commit" // OperationAbort is an abort operation OperationAbort = "abort" // OperationComment is a comment operation OperationComment = "comment" // OperationAssert is an assert operation OperationAssert = "assert" )
const ( //Strong RefType Strong RefType = "strong" //Weak RefType Weak RefType = "weak" //TypeInteger is equivalent to 'int' TypeInteger ExtendedType = "integer" //TypeReal is equivalent to 'float64' TypeReal ExtendedType = "real" //TypeBoolean is equivalent to 'bool' TypeBoolean ExtendedType = "boolean" //TypeString is equivalent to 'string' TypeString ExtendedType = "string" //TypeUUID is equivalent to 'libovsdb.UUID' TypeUUID ExtendedType = "uuid" //TypeEnum is an enumerator of type defined by Key.Type TypeEnum ExtendedType = "enum" //TypeMap is a map whose type depend on Key.Type and Value.Type TypeMap ExtendedType = "map" //TypeSet is a set whose type depend on Key.Type TypeSet ExtendedType = "set" )
Variables ¶
var UUIDColumn = ColumnSchema{ Type: TypeUUID, }
UUIDColumn is a static column that represents the _uuid column, common to all tables
var (
// Unlimited is used to express unlimited "Max"
Unlimited = -1
)
unlimited is not constant as we can't take the address of int constants
Functions ¶
func IsDefaultValue ¶
func IsDefaultValue(column *ColumnSchema, nativeElem interface{}) bool
IsDefaultValue checks if a provided native element corresponds to the default value of its designated column type
func NativeToOvs ¶
func NativeToOvs(column *ColumnSchema, rawElem interface{}) (interface{}, error)
NativeToOvs transforms an native type to a ovs type based on the column type information
func NativeToOvsAtomic ¶
NativeToOvsAtomic returns the OVS type of the atomic native value
func NativeType ¶
func NativeType(column *ColumnSchema) reflect.Type
NativeType returns the reflect.Type that can hold the value of a column OVS Type to Native Type convertions: OVS sets -> go slices OVS uuid -> go strings OVS map -> go map OVS enum -> go native type depending on the type of the enum key
func NativeTypeFromAtomic ¶
NativeTypeFromAtomic returns the native type that can hold a value of an AtomicType
func NewCancelArgs ¶
func NewCancelArgs(id interface{}) []interface{}
NewCancelArgs creates a new set of arguments for a cancel RPC
func NewEchoArgs ¶
func NewEchoArgs() []interface{}
NewEchoArgs creates a new set of arguments for an echo RPC
func NewErrWrongType ¶
NewErrWrongType creates a new ErrWrongType
func NewGetSchemaArgs ¶
func NewGetSchemaArgs(schema string) []interface{}
NewGetSchemaArgs creates a new set of arguments for a get_schemas RPC
func NewLockArgs ¶
func NewLockArgs(id interface{}) []interface{}
NewLockArgs creates a new set of arguments for a lock, steal or unlock RPC
func NewMonitorArgs ¶
func NewMonitorArgs(database string, value interface{}, requests map[string]MonitorRequest) []interface{}
NewMonitorArgs creates a new set of arguments for a monitor RPC
func NewMonitorCancelArgs ¶
func NewMonitorCancelArgs(value interface{}) []interface{}
NewMonitorCancelArgs creates a new set of arguments for a monitor_cancel RPC
func NewTransactArgs ¶
NewTransactArgs creates a new set of arguments for a transact RPC
func OvsToNative ¶
func OvsToNative(column *ColumnSchema, ovsElem interface{}) (interface{}, error)
OvsToNative transforms an ovs type to native one based on the column type information
func OvsToNativeAtomic ¶
OvsToNativeAtomic returns the native type of the basic ovs type
func ValidateCondition ¶
func ValidateCondition(column *ColumnSchema, function ConditionFunction, nativeValue interface{}) error
func ValidateMutation ¶
func ValidateMutation(column *ColumnSchema, mutator Mutator, value interface{}) error
ValidateMutation checks if the mutation value and mutator string area appropriate for a given column based on the rules specified RFC7047
Types ¶
type Aborted ¶
type Aborted struct {
// contains filtered or unexported fields
}
Aborted is described in RFC 7047: 5.2.8
type BaseType ¶
type BaseType struct { Type string Enum []interface{} // contains filtered or unexported fields }
BaseType is a base-type structure as per RFC7047
func (BaseType) MarshalJSON ¶
MarshalJSON marshals a base type to JSON
func (*BaseType) MaxInteger ¶
MaxInteger returns the minimum integer value RFC7047 specifies the minimum to be 2^63-1
func (*BaseType) MaxLength ¶
MaxLength returns the maximum string length RFC7047 doesn't specify a default, but we assume that it must 2^63-1
func (*BaseType) MaxReal ¶
MaxReal returns the maximum real value RFC7047 does not define a default, but this would be the maximum value held by a float64
func (*BaseType) MinInteger ¶
MinInteger returns the minimum integer value RFC7047 specifies the minimum to be -2^63
func (*BaseType) MinLength ¶
MinLength returns the minimum string length RFC7047 doesn't specify a default, but we assume that it must be >= 0
func (*BaseType) MinReal ¶
MinReal returns the minimum real value RFC7047 does not define a default, but we assume this to be the smallest non zero value a float64 could hold
func (*BaseType) RefTable ¶
RefTable returns the table to which a UUID type refers It will return an empty string if not set
func (*BaseType) RefType ¶
RefType returns the reference type for a UUID field RFC7047 infers the RefType is strong if omitted
func (*BaseType) UnmarshalJSON ¶
UnmarshalJSON unmarshals a json-formatted base type
type ColumnSchema ¶
type ColumnSchema struct { // According to RFC7047, "type" field can be, either an <atomic-type> // Or a ColumnType defined below. To try to simplify the usage, the // json message will be parsed manually and Type will indicate the "extended" // type. Depending on its value, more information may be available in TypeObj. // E.g: If Type == TypeEnum, TypeObj.Key.Enum contains the possible values Type ExtendedType TypeObj *ColumnType // contains filtered or unexported fields }
ColumnSchema is a column schema according to RFC7047
func (*ColumnSchema) Ephemeral ¶
func (c *ColumnSchema) Ephemeral() bool
Ephemeral returns whether a column is ephemeral
func (ColumnSchema) MarshalJSON ¶
func (c ColumnSchema) MarshalJSON() ([]byte, error)
MarshalJSON marshalls a column schema to JSON
func (*ColumnSchema) Mutable ¶
func (c *ColumnSchema) Mutable() bool
Mutable returns whether a column is mutable
func (*ColumnSchema) String ¶
func (c *ColumnSchema) String() string
String returns a string representation of the (native) column type
func (*ColumnSchema) UnmarshalJSON ¶
func (c *ColumnSchema) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshalls a json-formatted column
type ColumnType ¶
ColumnType is a type object as per RFC7047 "key": <base-type> required "value": <base-type> optional "min": <integer> optional (default: 1) "max": <integer> or "unlimited" optional (default: 1)
func (ColumnType) MarshalJSON ¶
func (c ColumnType) MarshalJSON() ([]byte, error)
MarshalJSON marshalls a column type to JSON
func (*ColumnType) Max ¶
func (c *ColumnType) Max() int
Max returns the maximum value of a ColumnType. -1 is Unlimited
func (*ColumnType) Min ¶
func (c *ColumnType) Min() int
Min returns the minimum value of a ColumnType
func (*ColumnType) UnmarshalJSON ¶
func (c *ColumnType) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals a json-formatted column type
type Condition ¶
type Condition struct { Column string Function ConditionFunction Value interface{} }
Condition is described in RFC 7047: 5.1
func NewCondition ¶
func NewCondition(column string, function ConditionFunction, value interface{}) Condition
NewCondition returns a new condition
func (Condition) MarshalJSON ¶
MarshalJSON marshals a condition to a 3 element JSON array
func (*Condition) UnmarshalJSON ¶
UnmarshalJSON converts a 3 element JSON array to a Condition
type ConditionFunction ¶
type ConditionFunction string
const ( // ConditionLessThan is the less than condition ConditionLessThan ConditionFunction = "<" // ConditionLessThanOrEqual is the less than or equal condition ConditionLessThanOrEqual ConditionFunction = "<=" // ConditionEqual is the equal condition ConditionEqual ConditionFunction = "==" // ConditionNotEqual is the not equal condition ConditionNotEqual ConditionFunction = "!=" // ConditionGreaterThan is the greater than condition ConditionGreaterThan ConditionFunction = ">" // ConditionGreaterThanOrEqual is the greater than or equal condition ConditionGreaterThanOrEqual ConditionFunction = ">=" // ConditionIncludes is the includes condition ConditionIncludes ConditionFunction = "includes" // ConditionExcludes is the excludes condition ConditionExcludes ConditionFunction = "excludes" )
func (ConditionFunction) Evaluate ¶
func (c ConditionFunction) Evaluate(a interface{}, b interface{}) (bool, error)
Evaluate will evaluate the condition on the two provided values The conditions operately differently depending on the type of the provided values. The behavjour is as described in RFC7047
type ConstraintViolation ¶
type ConstraintViolation struct {
// contains filtered or unexported fields
}
ConstraintViolation is described in RFC 7047: 4.1.3
func (*ConstraintViolation) Error ¶
func (e *ConstraintViolation) Error() string
Error implements the error interface
func (*ConstraintViolation) Operation ¶
func (e *ConstraintViolation) Operation() *Operation
Operation implements the OperationError interface
type DatabaseSchema ¶
type DatabaseSchema struct { Name string `json:"name"` Version string `json:"version"` Tables map[string]TableSchema `json:"tables"` }
DatabaseSchema is a database schema according to RFC7047
func SchemaFromFile ¶
func SchemaFromFile(f *os.File) (*DatabaseSchema, error)
SchemaFromFile returns a DatabaseSchema from a file
func (DatabaseSchema) Print ¶
func (schema DatabaseSchema) Print(w io.Writer)
Print will print the contents of the DatabaseSchema
func (DatabaseSchema) Table ¶
func (schema DatabaseSchema) Table(tableName string) *TableSchema
Table returns a TableSchema Schema for a given table and column name
func (DatabaseSchema) ValidateOperations ¶
func (schema DatabaseSchema) ValidateOperations(operations ...Operation) bool
ValidateOperations performs basic validation for operations against a DatabaseSchema
type DomainError ¶
type DomainError struct {
// contains filtered or unexported fields
}
DomainError is described in RFC 7047: 5.2.4
func (*DomainError) Error ¶
func (e *DomainError) Error() string
Error implements the error interface
func (*DomainError) Operation ¶
func (e *DomainError) Operation() *Operation
Operation implements the OperationError interface
type DuplicateUUIDName ¶
type DuplicateUUIDName struct {
// contains filtered or unexported fields
}
DuplicateUUIDName is described in RFC7047 5.2.1
func (*DuplicateUUIDName) Error ¶
func (e *DuplicateUUIDName) Error() string
Error implements the error interface
func (*DuplicateUUIDName) Operation ¶
func (e *DuplicateUUIDName) Operation() *Operation
Operation implements the OperationError interface
type ErrWrongType ¶
type ErrWrongType struct {
// contains filtered or unexported fields
}
ErrWrongType describes typing error
func (*ErrWrongType) Error ¶
func (e *ErrWrongType) Error() string
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a generic OVSDB Error type that implements the OperationError and error interfaces
type ExtendedType ¶
type ExtendedType = string
ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set
type IOError ¶
type IOError struct {
// contains filtered or unexported fields
}
IOError is described in RFC7047: 4.1.3
type MonitorRequest ¶
type MonitorRequest struct { Columns []string `json:"columns,omitempty"` Select *MonitorSelect `json:"select,omitempty"` }
MonitorRequest represents a monitor request according to RFC7047
type MonitorRequests ¶
type MonitorRequests struct {
Requests map[string]MonitorRequest `json:"requests"`
}
MonitorRequests represents a group of monitor requests according to RFC7047 We cannot use MonitorRequests by inlining the MonitorRequest Map structure till GoLang issue #6213 makes it. The only option is to go with raw map[string]interface{} option :-( that sucks ! Refer to client.go : MonitorAll() function for more details
type MonitorSelect ¶
type MonitorSelect struct {
// contains filtered or unexported fields
}
MonitorSelect represents a monitor select according to RFC7047
func NewDefaultMonitorSelect ¶
func NewDefaultMonitorSelect() *MonitorSelect
NewDefaultMonitorSelect returns a new MonitorSelect with default values
func NewMonitorSelect ¶
func NewMonitorSelect(initial, insert, delete, modify bool) *MonitorSelect
NewMonitorSelect returns a new MonitorSelect with the provided values
func (MonitorSelect) Delete ¶
func (m MonitorSelect) Delete() bool
Delete returns whether we will receive updates for deletions
func (MonitorSelect) Initial ¶
func (m MonitorSelect) Initial() bool
Initial returns whether or not an initial response will be sent
func (MonitorSelect) Insert ¶
func (m MonitorSelect) Insert() bool
Insert returns whether we will receive updates for inserts
func (MonitorSelect) MarshalJSON ¶
func (m MonitorSelect) MarshalJSON() ([]byte, error)
func (MonitorSelect) Modify ¶
func (m MonitorSelect) Modify() bool
Modify returns whether we will receive updates for modifications
func (*MonitorSelect) UnmarshalJSON ¶
func (m *MonitorSelect) UnmarshalJSON(data []byte) error
type Mutation ¶
Mutation is described in RFC 7047: 5.1
func NewMutation ¶
NewMutation returns a new mutation
func (Mutation) MarshalJSON ¶
MarshalJSON marshals a mutation to a 3 element JSON array
func (*Mutation) UnmarshalJSON ¶
UnmarshalJSON converts a 3 element JSON array to a Mutation
type Mutator ¶
type Mutator string
const ( // MutateOperationDelete is the delete mutator MutateOperationDelete Mutator = "delete" // MutateOperationInsert is the insert mutator MutateOperationInsert Mutator = "insert" // MutateOperationAdd is the add mutator MutateOperationAdd Mutator = "+=" // MutateOperationSubtract is the subtract mutator MutateOperationSubtract Mutator = "-=" // MutateOperationMultiply is the multiply mutator MutateOperationMultiply Mutator = "*=" // MutateOperationDivide is the divide mutator MutateOperationDivide Mutator = "/=" // MutateOperationModulo is the modulo mutator MutateOperationModulo Mutator = "%=" )
type NotOwner ¶
type NotOwner struct {
// contains filtered or unexported fields
}
NotOwner is described in RFC 7047: 5.2.9
type NotSupported ¶
type NotSupported struct {
// contains filtered or unexported fields
}
NotSupported is described in RFC 7047: 5.2.7
func (*NotSupported) Error ¶
func (e *NotSupported) Error() string
Error implements the error interface
func (*NotSupported) Operation ¶
func (e *NotSupported) Operation() *Operation
Operation implements the OperationError interface
type NotificationHandler ¶
type NotificationHandler interface { // RFC 7047 section 4.1.6 Update Notification Update(context interface{}, tableUpdates TableUpdates) // RFC 7047 section 4.1.9 Locked Notification Locked([]interface{}) // RFC 7047 section 4.1.10 Stolen Notification Stolen([]interface{}) // RFC 7047 section 4.1.11 Echo Notification Echo([]interface{}) Disconnected() }
NotificationHandler is the interface that must be implemented to receive notifcations
type Operation ¶
type Operation struct { Op string `json:"op"` Table string `json:"table"` Row Row `json:"row,omitempty"` Rows []Row `json:"rows,omitempty"` Columns []string `json:"columns,omitempty"` Mutations []Mutation `json:"mutations,omitempty"` Timeout int `json:"timeout,omitempty"` Where []Condition `json:"where,omitempty"` Until string `json:"until,omitempty"` Durable *bool `json:"durable,omitempty"` Comment *string `json:"comment,omitempty"` Lock *string `json:"lock,omitempty"` UUIDName string `json:"uuid-name,omitempty"` }
Operation represents an operation according to RFC7047 section 5.2
func (Operation) MarshalJSON ¶
MarshalJSON marshalls 'Operation' to a byte array For 'select' operations, we don't omit the 'Where' field to allow selecting all rows of a table
type OperationError ¶
type OperationError interface { error // Operation is a pointer to the operation which caused the error Operation() *Operation }
OperationError represents an error that occurred as part of an OVSDB Operation
func CheckOperationResults ¶
func CheckOperationResults(result []OperationResult, ops []Operation) ([]OperationError, error)
CheckOperationResults checks whether the provided operation was a success If the operation was a success, it will return nil, nil If the operation failed, due to a error committing the transaction it will return nil, error. Finally, in the case where one or more of the operations in the transaction failed, we return []OperationErrors, error Within []OperationErrors, the OperationErrors.Index() corresponds to the same index in the original Operations struct. You may also perform type assertions against the error so the caller can decide how best to handle it
type OperationResult ¶
type OperationResult struct { Count int `json:"count,omitempty"` Error string `json:"error,omitempty"` Details string `json:"details,omitempty"` UUID UUID `json:"uuid,omitempty"` Rows []Row `json:"rows,omitempty"` }
OperationResult is the result of an Operation
type OvsMap ¶
type OvsMap struct {
GoMap map[interface{}]interface{}
}
OvsMap is the JSON map structure used for OVSDB RFC 7047 uses the following notation for map as JSON doesnt support non-string keys for maps. A 2-element JSON array that represents a database map value. The first element of the array must be the string "map", and the second element must be an array of zero or more <pair>s giving the values in the map. All of the <pair>s must have the same key and value types.
func (OvsMap) MarshalJSON ¶
MarshalJSON marshalls an OVSDB style Map to a byte array
func (*OvsMap) UnmarshalJSON ¶
UnmarshalJSON unmarshalls an OVSDB style Map from a byte array
type OvsSet ¶
type OvsSet struct {
GoSet []interface{}
}
OvsSet is an OVSDB style set RFC 7047 has a weird (but understandable) notation for set as described as : Either an <atom>, representing a set with exactly one element, or a 2-element JSON array that represents a database set value. The first element of the array must be the string "set", and the second element must be an array of zero or more <atom>s giving the values in the set. All of the <atom>s must have the same type.
func (OvsSet) MarshalJSON ¶
MarshalJSON wil marshal an OVSDB style Set in to a JSON byte array
func (*OvsSet) UnmarshalJSON ¶
UnmarshalJSON will unmarshal a JSON byte array to an OVSDB style Set
type RangeError ¶
type RangeError struct {
// contains filtered or unexported fields
}
RangeError is described in RFC 7047: 5.2.4
func (*RangeError) Operation ¶
func (e *RangeError) Operation() *Operation
Operation implements the OperationError interface
type ReferentialIntegrityViolation ¶
type ReferentialIntegrityViolation struct {
// contains filtered or unexported fields
}
ReferentialIntegrityViolation is explained in RFC 7047 4.1.3
func (*ReferentialIntegrityViolation) Error ¶
func (e *ReferentialIntegrityViolation) Error() string
Error implements the error interface
func (*ReferentialIntegrityViolation) Operation ¶
func (e *ReferentialIntegrityViolation) Operation() *Operation
Operation implements the OperationError interface
type ResourcesExhausted ¶
type ResourcesExhausted struct {
// contains filtered or unexported fields
}
ResourcesExhausted is described in RFC 7047: 4.1.3
func (*ResourcesExhausted) Error ¶
func (e *ResourcesExhausted) Error() string
Error implements the error interface
func (*ResourcesExhausted) Operation ¶
func (e *ResourcesExhausted) Operation() *Operation
Operation implements the OperationError interface
type Row ¶
type Row map[string]interface{}
Row is a table Row according to RFC7047
func (*Row) UnmarshalJSON ¶
UnmarshalJSON unmarshalls a byte array to an OVSDB Row
type RowUpdate ¶
RowUpdate represents a row update according to RFC7047
type TableSchema ¶
type TableSchema struct { Columns map[string]*ColumnSchema `json:"columns"` Indexes [][]string `json:"indexes,omitempty"` }
TableSchema is a table schema according to RFC7047
func (TableSchema) Column ¶
func (t TableSchema) Column(columnName string) *ColumnSchema
Column returns the Column object for a specific column name
type TableUpdate ¶
TableUpdate is an object that maps from the row's UUID to a RowUpdate
func (TableUpdate) AddRowUpdate ¶
func (t TableUpdate) AddRowUpdate(uuid string, update *RowUpdate)
type TableUpdates ¶
type TableUpdates map[string]TableUpdate
TableUpdates is an object that maps from a table name to a TableUpdate
func (TableUpdates) AddTableUpdate ¶
func (t TableUpdates) AddTableUpdate(table string, update TableUpdate)
AddTableUpdate adds a new TableUpdate to a TableUpdates
func (TableUpdates) Merge ¶
func (t TableUpdates) Merge(update TableUpdates)
type TimedOut ¶
type TimedOut struct {
// contains filtered or unexported fields
}
TimedOut is described in RFC 7047: 5.2.6
type TransactResponse ¶
type TransactResponse struct { Result []OperationResult `json:"result"` Error string `json:"error"` }
TransactResponse represents the response to a Transact Operation
type UUID ¶
type UUID struct {
GoUUID string `json:"uuid"`
}
UUID is a UUID according to RFC7047
func (UUID) MarshalJSON ¶
MarshalJSON will marshal an OVSDB style UUID to a JSON encoded byte array
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON will unmarshal a JSON encoded byte array to a OVSDB style UUID