go-openvswitch: github.com/digitalocean/go-openvswitch/ovsdb Index | Examples | Files | Directories

package ovsdb

import "github.com/digitalocean/go-openvswitch/ovsdb"

Package ovsdb implements an OVSDB client, as described in RFC 7047.

Index

Examples

Package Files

client.go doc.go result.go rpc.go transact.go

type Client Uses

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.

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.

Code:

// 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)
}

func Dial Uses

func Dial(network, addr string, options ...OptionFunc) (*Client, error)

Dial dials a connection to an OVSDB server and returns a Client.

func New Uses

func New(conn net.Conn, options ...OptionFunc) (*Client, error)

New wraps an existing connection to an OVSDB server and returns a Client.

func (*Client) Close Uses

func (c *Client) Close() error

Close closes a Client's connection and cleans up its resources.

func (*Client) Echo Uses

func (c *Client) Echo(ctx context.Context) error

Echo verifies that the OVSDB connection is alive, and can be used to keep the connection alive.

func (*Client) ListDatabases Uses

func (c *Client) ListDatabases(ctx context.Context) ([]string, error)

ListDatabases returns the name of all databases known to the OVSDB server.

func (*Client) Stats Uses

func (c *Client) Stats() ClientStats

Stats returns a ClientStats with current statistics for the Client.

func (*Client) Transact Uses

func (c *Client) Transact(ctx context.Context, db string, ops []TransactOp) ([]Row, error)

Transact creates and executes a transaction on the specified database. Each operation is applied in the order they appear in ops.

type ClientStats Uses

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 Uses

type Cond struct {
    Column, Function, Value string
}

A Cond is a conditional expression which is evaluated by the OVSDB server in a transaction.

func Equal Uses

func Equal(column, value string) Cond

Equal creates a Cond that ensures a column's value equals the specified value.

func (Cond) MarshalJSON Uses

func (c Cond) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type Error Uses

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.

func (*Error) Error Uses

func (e *Error) Error() string

type OptionFunc Uses

type OptionFunc func(c *Client) error

An OptionFunc is a function which can configure a Client.

func Debug Uses

func Debug(ll *log.Logger) OptionFunc

Debug enables debug logging for a Client.

func EchoInterval Uses

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 Uses

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 Uses

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 Uses

func (s Select) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

type TransactOp Uses

type TransactOp interface {
    json.Marshaler
}

A TransactOp is an operation that can be applied with Client.Transact.

Directories

PathSynopsis
internal/jsonrpcPackage jsonrpc is a minimal JSON-RPC 1.0 implementation.

Package ovsdb imports 13 packages (graph). Updated 2019-03-15. Refresh now. Tools for package owners.