apis

package
v0.0.0-...-f33ab34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SAMPLE_NOTIFICATION_MIN_INTERVAL = 20
)

Minimum Interval for sample notification

Variables

This section is empty.

Functions

func EntryFields

func EntryFields(v db.Value) []string

EntryFields returns the list of field names in a DB entry. Ignores the dummy NULL field and also removes @ suffix of array fields.

func PathToString

func PathToString(p *gnmi.Path) string

PathToString returns a string representation of gnmi path

Types

type DeleteActionType

type DeleteActionType uint8

DeleteActionType indicates how db delete be handled w.r.t a path. By default, db delete will be treated as delete of mapped path.

const (
	// InspectPathOnDelete action attempts Get of mapped path
	// on db delete; notifies delete/update accordingly
	InspectPathOnDelete DeleteActionType = iota + 1
	// InspectLeafOnDelete action attempts Get of each mapped leaf
	// on db delete; and notifies delete/update for each
	InspectLeafOnDelete
)

type EntryDiff

type EntryDiff struct {
	OldValue      db.Value // value before change; empty during entry create
	NewValue      db.Value // changed db value; empty during entry delete
	EntryCreated  bool     // true if entry being created
	EntryDeleted  bool     // true if entry being deleted
	CreatedFields []string // fields added during entry update
	UpdatedFields []string // fields modified during entry update
	DeletedFields []string // fields deleted during entry update
}

EntryDiff holds diff of two versions of a single db entry. It contains both old & new db.Value objects and list changed field names. Dummy "NULL" fields are ignored; array field names will have "@" suffix.

func EntryCompare

func EntryCompare(old, new db.Value) *EntryDiff

EntryCompare function compares two db.Value objects representing two versions of a single db entry. Changes are returned as a DBEntryDiff pointer.

func (*EntryDiff) IsEmpty

func (d *EntryDiff) IsEmpty() bool

IsEmpty returns true if this EntryDiff has no diff data -- either not initialized or both old and new values are identical.

func (*EntryDiff) String

func (d *EntryDiff) String() string

type Notification

type Notification struct {
	// Path is an absolute gnmi path of the changed yang container
	// or list instance. MUST NOT be a leaf path.
	Path string
	// Delete is the list of deleted subpaths (relative to Path).
	// Should contain one empty string if the Path itself was deleted.
	// Can be a nil or empty list if there are no delete paths.
	Delete []string
	// Update holds all the updated values (new+modified) within the Path.
	// MUST be the YGOT struct corresponding to the Path.
	// Can be nil if there are no updated values; or specified as UpdatePaths.
	Update ygot.ValidatedGoStruct
	// UpdatePaths holds the list of updated subpaths (relative to Path).
	// Nil/empty if there are no updates or specified as Update ygot value.
	// Update and UpdatePaths MUST NOT overlap to prevent duplicate notifications.
	UpdatePaths []string
}

Notification is a message containing deleted and updated values for a yang path.

type NotificationContext

type NotificationContext struct {
	Path      *gnmi.Path    // subscribe path, can include wildcards
	Db        *db.DB        // db in which the entry was modified
	Table     *db.TableSpec // table for the modified entry
	Key       *db.Key       // key for modified entry
	EntryDiff               // diff info for modified entry
	AllDb     [db.MaxDB]*db.DB
	Opaque    interface{} // app specific opaque data
}

NotificationContext contains the subscribed path and details of a DB entry change that may result in a notification message.

func (*NotificationContext) String

func (nc *NotificationContext) String() string

type NotificationSender

type NotificationSender interface {
	Send(*Notification) // Send a notification message to clients
}

NotificationSender provides methods to send notification message to the clients. Translib subscribe infra implements this interface.

type ProcessOnChange

type ProcessOnChange func(*NotificationContext, NotificationSender)

ProcessOnChange is a callback function to generate notification messages from a DB entry change data. Apps can implement their own diff & notify logic and plugin into the translib onchange subscribe infra. This callback receives a NotificationContext object containing change details of one DB entry and a NotificationSender interface to push translated messages. NotificationContext.Path is the subscribed path, which indicates the yang attributes that can be included in the notification. Implementations should inspect the provided subscribe path and DB changes; and translate them into zero, one or more notifications and push them out.

func (ProcessOnChange) String

func (p ProcessOnChange) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL