dispatcher

package
v0.1.290 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Resources = map[string][]*EventHandler{}

Functions

func Register

func Register(name string, e []*EventHandler)

Types

type Dispatcher

type Dispatcher struct {
	// contains filtered or unexported fields
}

func New

func New() *Dispatcher

func (*Dispatcher) GetHandlerFunc

func (r *Dispatcher) GetHandlerFunc(path []string) interface{}

func (*Dispatcher) GetPathElem

func (r *Dispatcher) GetPathElem(p *gnmi.Path) []*gnmi.PathElem

func (*Dispatcher) GetTree

func (r *Dispatcher) GetTree() *dtree.Tree

func (*Dispatcher) Init

func (r *Dispatcher) Init()

func (*Dispatcher) Register

func (r *Dispatcher) Register(pe []*gnmi.PathElem, d interface{}) error

type DispatcherConfig

type DispatcherConfig struct {
	PathElem []*gnmi.PathElem
}

type DispatcherData

type DispatcherData struct {
	Kind    EventHandlerKind
	Handler func(log logging.Logger, cc, sc *cache.Cache, prefix *gnmi.Path, p []*gnmi.PathElem, d interface{}) Handler
}

type EventHandler

type EventHandler struct {
	PathElem []*gnmi.PathElem
	Kind     EventHandlerKind
	Handler  HandleConfigEventFunc
}

type EventHandlerKind

type EventHandlerKind string

A EventHandlerKind represents a kind of event handler

const (
	// create
	EventHandlerCreate EventHandlerKind = "Create"
	// update
	EventHandlerEvent EventHandlerKind = "Event"
)

Operations Kinds.

func (*EventHandlerKind) String

func (o *EventHandlerKind) String() string

type HandleConfigEventFunc

type HandleConfigEventFunc func(log logging.Logger, cc, sc *cache.Cache, prefix *gnmi.Path, p []*gnmi.PathElem, d interface{}) Handler

type Handler

type Handler interface {
	HandleConfigEvent(o Operation, prefix *gnmi.Path, pe []*gnmi.PathElem, d interface{}) (Handler, error)
	SetParent(interface{}) error
	SetRootSchema(rs *yentry.Entry)
	GetChildren() map[string]string
	UpdateConfig(interface{}) error
	UpdateStateCache() error
	DeleteStateCache() error
	WithLogging(log logging.Logger)
	WithStateCache(c *cache.Cache)
	WithConfigCache(c *cache.Cache)
	WithPrefix(p *gnmi.Path)
	WithPathElem(pe []*gnmi.PathElem)
	WithRootSchema(rs *yentry.Entry)
}

type HandlerOption

type HandlerOption func(Handler)

func WithConfigCache

func WithConfigCache(c *cache.Cache) HandlerOption

WithConfigCache initializes the config cache.

func WithLogging

func WithLogging(log logging.Logger) HandlerOption

func WithPathElem

func WithPathElem(pe []*gnmi.PathElem) HandlerOption

func WithPrefix

func WithPrefix(p *gnmi.Path) HandlerOption

func WithRootSchema

func WithRootSchema(rs *yentry.Entry) HandlerOption

func WithStateCache

func WithStateCache(c *cache.Cache) HandlerOption

WithStateCache initializes the state cache.

type Operation

type Operation string

A Operation represents a crud operation

const (
	// create
	//OperationCreate Operation = "Create"
	// update
	OperationUpdate Operation = "Update"
	// delete
	OperationDelete Operation = "Delete"
)

Operations Kinds.

func (*Operation) String

func (o *Operation) String() string

type Resource

type Resource struct {
	Log         logging.Logger
	ConfigCache *cache.Cache
	StateCache  *cache.Cache
	PathElem    *gnmi.PathElem
	Prefix      *gnmi.Path
	RootSchema  *yentry.Entry
	Key         string
}

Jump to

Keyboard shortcuts

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