Documentation ¶
Overview ¶
Package cache provides a cache of model.Model elements that can be used in an OVSDB client or server.
The cache can be accessed using a simple API:
cache.Table("Open_vSwitch").Row("<ovs-uuid>")
It implements the ovsdb.NotificationHandler interface such that it can be populated automatically by update notifications
It also contains an eventProcessor where callers may registers functions that will get called on every Add/Update/Delete event.
Index ¶
- type Data
- type EventHandler
- type EventHandlerFuncs
- type IndexExistsError
- type RowCache
- func (r *RowCache) Create(uuid string, m model.Model, checkIndexes bool) error
- func (r *RowCache) Delete(uuid string) error
- func (r *RowCache) Index(columns ...string) (map[interface{}]string, error)
- func (r *RowCache) Len() int
- func (r *RowCache) Row(uuid string) model.Model
- func (r *RowCache) RowByModel(m model.Model) model.Model
- func (r *RowCache) Rows() []string
- func (r *RowCache) Update(uuid string, m model.Model, checkIndexes bool) error
- type TableCache
- func (t *TableCache) AddEventHandler(handler EventHandler)
- func (t *TableCache) CreateModel(tableName string, row *ovsdb.Row, uuid string) (model.Model, error)
- func (t *TableCache) DBModel() *model.DBModel
- func (t *TableCache) Disconnected()
- func (t *TableCache) Echo([]interface{})
- func (t *TableCache) Locked([]interface{})
- func (t *TableCache) Mapper() *mapper.Mapper
- func (t *TableCache) Populate(tableUpdates ovsdb.TableUpdates)
- func (t *TableCache) Purge(schema *ovsdb.DatabaseSchema)
- func (t *TableCache) Run(stopCh <-chan struct{})
- func (t *TableCache) Stolen([]interface{})
- func (t *TableCache) Table(name string) *RowCache
- func (t *TableCache) Tables() []string
- func (t *TableCache) Update(context interface{}, tableUpdates ovsdb.TableUpdates)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventHandler ¶
type EventHandler interface { OnAdd(table string, model model.Model) OnUpdate(table string, old model.Model, new model.Model) OnDelete(table string, model model.Model) }
EventHandler can handle events when the contents of the cache changes
type EventHandlerFuncs ¶
type EventHandlerFuncs struct { AddFunc func(table string, model model.Model) UpdateFunc func(table string, old model.Model, new model.Model) DeleteFunc func(table string, model model.Model) }
EventHandlerFuncs is a wrapper for the EventHandler interface It allows a caller to only implement the functions they need
func (*EventHandlerFuncs) OnAdd ¶
func (e *EventHandlerFuncs) OnAdd(table string, model model.Model)
OnAdd calls AddFunc if it is not nil
type IndexExistsError ¶
type IndexExistsError struct {
// contains filtered or unexported fields
}
func NewIndexExistsError ¶
func NewIndexExistsError(table string, value interface{}, index index, new, existing string) *IndexExistsError
func (*IndexExistsError) Error ¶
func (i *IndexExistsError) Error() string
type RowCache ¶
type RowCache struct {
// contains filtered or unexported fields
}
RowCache is a collections of Models hashed by UUID
func (*RowCache) RowByModel ¶ added in v0.6.0
RowByModel searches the cache using a the indexes for a provided model
type TableCache ¶
type TableCache struct { ovsdb.NotificationHandler // contains filtered or unexported fields }
TableCache contains a collection of RowCaches, hashed by name, and an array of EventHandlers that respond to cache updates It implements the ovsdb.NotifcationHandler interface so it may handle update notifications
func NewTableCache ¶
func NewTableCache(schema *ovsdb.DatabaseSchema, dbModel *model.DBModel, data Data) (*TableCache, error)
NewTableCache creates a new TableCache
func (*TableCache) AddEventHandler ¶
func (t *TableCache) AddEventHandler(handler EventHandler)
AddEventHandler registers the supplied EventHandler to receive cache events
func (*TableCache) CreateModel ¶
func (t *TableCache) CreateModel(tableName string, row *ovsdb.Row, uuid string) (model.Model, error)
CreateModel creates a new Model instance based on the Row information
func (*TableCache) DBModel ¶
func (t *TableCache) DBModel() *model.DBModel
DBModel returns the DBModel
func (*TableCache) Disconnected ¶
func (t *TableCache) Disconnected()
Disconnected implements the disconnected method of the NotificationHandler interface
func (*TableCache) Echo ¶
func (t *TableCache) Echo([]interface{})
Echo implements the echo method of the NotificationHandler interface
func (*TableCache) Locked ¶
func (t *TableCache) Locked([]interface{})
Locked implements the locked method of the NotificationHandler interface
func (*TableCache) Populate ¶
func (t *TableCache) Populate(tableUpdates ovsdb.TableUpdates)
Populate adds data to the cache and places an event on the channel
func (*TableCache) Purge ¶ added in v0.6.0
func (t *TableCache) Purge(schema *ovsdb.DatabaseSchema)
Purge drops all data in the cache and reinitializes it using the provided schema
func (*TableCache) Run ¶
func (t *TableCache) Run(stopCh <-chan struct{})
Run starts the event processing loop. It blocks until the channel is closed.
func (*TableCache) Stolen ¶
func (t *TableCache) Stolen([]interface{})
Stolen implements the stolen method of the NotificationHandler interface
func (*TableCache) Table ¶
func (t *TableCache) Table(name string) *RowCache
Table returns the a Table from the cache with a given name
func (*TableCache) Tables ¶
func (t *TableCache) Tables() []string
Tables returns a list of table names that are in the cache
func (*TableCache) Update ¶
func (t *TableCache) Update(context interface{}, tableUpdates ovsdb.TableUpdates)
Update implements the update method of the NotificationHandler interface this populates the cache with new updates