Documentation
¶
Index ¶
- Constants
- func NewCancelArgs(id interface{}) []interface{}
- func NewCondition(column string, function string, value interface{}) []interface{}
- 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 NewMutation(column string, mutator string, value interface{}) []interface{}
- func NewTransactArgs(database string, operations ...Operation) []interface{}
- type ColumnSchema
- type Config
- type DatabaseSchema
- type MonitorRequest
- type MonitorRequests
- type MonitorSelect
- type NotificationHandler
- type Operation
- type OperationResult
- type OvsMap
- type OvsSet
- type OvsdbClient
- func (ovs OvsdbClient) Disconnect()
- func (ovs OvsdbClient) GetSchema(dbName string) (*DatabaseSchema, error)
- func (ovs OvsdbClient) ListDbs() ([]string, error)
- func (ovs OvsdbClient) Monitor(database string, jsonContext interface{}, requests map[string]MonitorRequest) (*TableUpdates, error)
- func (ovs OvsdbClient) MonitorAll(database string, jsonContext interface{}) (*TableUpdates, error)
- func (ovs OvsdbClient) MonitorCancel(database string, jsonContext interface{}) error
- func (ovs *OvsdbClient) Register(handler NotificationHandler)
- func (ovs OvsdbClient) Transact(database string, operation ...Operation) ([]OperationResult, error)
- func (ovs *OvsdbClient) Unregister(handler NotificationHandler) error
- type OvsdbError
- type ResultRow
- type Row
- type RowUpdate
- type TableSchema
- type TableUpdate
- type TableUpdates
- type TransactResponse
- type UUID
Constants ¶
const ( SSL = "ssl" TCP = "tcp" UNIX = "unix" )
Variables ¶
This section is empty.
Functions ¶
func NewCancelArgs ¶
func NewCancelArgs(id interface{}) []interface{}
NewCancelArgs creates a new set of arguments for a cancel RPC
func NewCondition ¶
NewCondition creates a new condition as specified in RFC7047
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 NewMutation ¶
NewMutation creates a new mutation as specified in RFC7047
func NewTransactArgs ¶
NewTransactArgs creates a new set of arguments for a transact RPC
Types ¶
type ColumnSchema ¶
type ColumnSchema struct {
Name string `json:"name"`
Type interface{} `json:"type"`
Ephemeral bool `json:"ephemeral,omitempty"`
Mutable bool `json:"mutable,omitempty"`
}
ColumnSchema is a column schema according to RFC7047
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 (DatabaseSchema) Print ¶
func (schema DatabaseSchema) Print(w io.Writer)
Print will print the contents of the DatabaseSchema
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,overflow"`
}
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 {
Initial bool `json:"initial,omitempty"`
Insert bool `json:"insert,omitempty"`
Delete bool `json:"delete,omitempty"`
Modify bool `json:"modify,omitempty"`
}
MonitorSelect represents a monitor select according to RFC7047
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(*OvsdbClient)
}
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 map[string]interface{} `json:"row,omitempty"`
Rows []map[string]interface{} `json:"rows,omitempty"`
Columns []string `json:"columns,omitempty"`
Mutations []interface{} `json:"mutations,omitempty"`
Timeout int `json:"timeout,omitempty"`
Where []interface{} `json:"where,omitempty"`
Until string `json:"until,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 dont omit the 'Where' field to allow selecting all rows of a table
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 []ResultRow `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 wierd (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 OvsdbClient ¶
type OvsdbClient struct {
Schema map[string]DatabaseSchema
// contains filtered or unexported fields
}
OvsdbClient is an OVSDB client
func Connect ¶
func Connect(endpoints string, tlsConfig *tls.Config) (*OvsdbClient, error)
Connect to ovn, using endpoint in format ovsdb Connection Methods If address is empty, use default address for specified protocol
func (OvsdbClient) Disconnect ¶
func (ovs OvsdbClient) Disconnect()
Disconnect will close the OVSDB connection
func (OvsdbClient) GetSchema ¶
func (ovs OvsdbClient) GetSchema(dbName string) (*DatabaseSchema, error)
GetSchema returns the schema in use for the provided database name RFC 7047 : get_schema
func (OvsdbClient) ListDbs ¶
func (ovs OvsdbClient) ListDbs() ([]string, error)
ListDbs returns the list of databases on the server RFC 7047 : list_dbs
func (OvsdbClient) Monitor ¶
func (ovs OvsdbClient) Monitor(database string, jsonContext interface{}, requests map[string]MonitorRequest) (*TableUpdates, error)
Monitor will provide updates for a given table/column RFC 7047 : monitor
func (OvsdbClient) MonitorAll ¶
func (ovs OvsdbClient) MonitorAll(database string, jsonContext interface{}) (*TableUpdates, error)
MonitorAll is a convenience method to monitor every table/column
func (OvsdbClient) MonitorCancel ¶
func (ovs OvsdbClient) MonitorCancel(database string, jsonContext interface{}) error
MonitorCancel will request cancel a previously issued monitor request RFC 7047 : monitor_cancel
func (*OvsdbClient) Register ¶
func (ovs *OvsdbClient) Register(handler NotificationHandler)
Register registers the supplied NotificationHandler to recieve OVSDB Notifications
func (OvsdbClient) Transact ¶
func (ovs OvsdbClient) Transact(database string, operation ...Operation) ([]OperationResult, error)
Transact performs the provided Operation's on the database RFC 7047 : transact
func (*OvsdbClient) Unregister ¶
func (ovs *OvsdbClient) Unregister(handler NotificationHandler) error
Unregister the supplied NotificationHandler to not recieve OVSDB Notifications anymore
type OvsdbError ¶
OvsdbError is an OVS Error Condition
type ResultRow ¶
type ResultRow map[string]interface{}
ResultRow is an properly unmarshalled row returned by Transact
func (*ResultRow) UnmarshalJSON ¶
UnmarshalJSON unmarshalls a byte array to an OVSDB Row
type Row ¶
type Row struct {
Fields 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 ¶
type RowUpdate struct {
UUID UUID `json:"-,omitempty"`
New Row `json:"new,omitempty"`
Old Row `json:"old,omitempty"`
}
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
type TableUpdate ¶
TableUpdate represents a table update according to RFC7047
type TableUpdates ¶
type TableUpdates struct {
Updates map[string]TableUpdate `json:"updates,overflow"`
}
TableUpdates is a collection of TableUpdate entries We cannot use TableUpdates directly by json encoding by inlining the TableUpdate Map structure till GoLang issue #6213 makes it. The only option is to go with raw map[string]map[string]interface{} option :-( that sucks ! Refer to client.go : MonitorAll() function for more details
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