Documentation ¶
Overview ¶
Package ovsdb implements an OVSDB client, as described in RFC 7047.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is an OVSDB client. Clients can be customized by using OptionFuncs in the Dial and New functions.
All methods on the Client that accept a context.Context can use the context to cancel or time out requests. Some methods may use the context for advanced use cases. If this is the case, the documentation for the method will explain these use cases.
Example (ListDatabases) ¶
This example demonstrates basic usage of a Client. The Client connects to ovsdb-server and requests a list of all databases known to the server.
package main import ( "context" "fmt" "log" "time" "github.com/digitalocean/go-openvswitch/ovsdb" ) func main() { // Dial an OVSDB connection and create a *ovsdb.Client. c, err := ovsdb.Dial("unix", "/var/run/openvswitch/db.sock") if err != nil { log.Fatalf("failed to dial: %v", err) } // Be sure to close the connection! defer c.Close() // Ask ovsdb-server for all of its databases, but only allow the RPC // a limited amount of time to complete before timing out. ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() dbs, err := c.ListDatabases(ctx) if err != nil { log.Fatalf("failed to list databases: %v", err) } for _, d := range dbs { fmt.Println(d) } }
Output:
func Dial ¶
func Dial(network, addr string, options ...OptionFunc) (*Client, error)
Dial dials a connection to an OVSDB server and returns a Client.
func New ¶
func New(conn net.Conn, options ...OptionFunc) (*Client, error)
New wraps an existing connection to an OVSDB server and returns a Client.
func (*Client) Echo ¶
Echo verifies that the OVSDB connection is alive, and can be used to keep the connection alive.
func (*Client) ListDatabases ¶
ListDatabases returns the name of all databases known to the OVSDB server.
func (*Client) Stats ¶
func (c *Client) Stats() ClientStats
Stats returns a ClientStats with current statistics for the Client.
type ClientStats ¶
type ClientStats struct { // Statistics about the Client's internal callbacks. Callbacks struct { // The number of callback hooks currently registered and waiting // for RPC responses. Current int } // Statistics about the Client's internal echo RPC loop. EchoLoop struct { // The number of successful and failed echo RPCs in the loop. Success, Failure int } }
ClientStats contains statistics about a Client.
type Cond ¶
type Cond struct {
Column, Function, Value string
}
A Cond is a conditional expression which is evaluated by the OVSDB server in a transaction.
func (Cond) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type Error ¶
type Error struct { Err string `json:"error"` Details string `json:"details"` Syntax string `json:"syntax"` }
An Error is an error returned by an OVSDB server. Its fields can be used to determine the cause of an error.
type OptionFunc ¶
An OptionFunc is a function which can configure a Client.
func EchoInterval ¶
func EchoInterval(d time.Duration) OptionFunc
EchoInterval specifies an interval at which the Client will send echo RPCs to an OVSDB server to keep the connection alive. Note that the OVSDB server may also send its own echo RPCs to the Client, and the Client will always reply to those on behalf of the user.
If this option is not used, the Client will only send echo RPCs when the server sends an echo RPC to it.
Specify a duration of 0 to disable sending background echo RPCs at a fixed interval.
type Row ¶
type Row map[string]interface{}
A Row is a database row. Its keys are database column names, and its values are database column values.
type Select ¶
type Select struct { // The name of the table to select from. Table string // Zero or more Conds for conditional select. Where []Cond }
Select is a TransactOp which fetches information from a database.
func (Select) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
type TransactOp ¶
A TransactOp is an operation that can be applied with Client.Transact.