collector

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSubscriptionRequest

func CreateSubscriptionRequest(target, subName string, paths []*gnmi.Path) (*gnmi.SubscribeRequest, error)

CreateSubscriptionRequest create a gnmi subscription

Types

type Collector

type Collector interface {
	Lock()
	Unlock()
	GetSubscription(subName string) bool
	StopSubscription(ctx context.Context, sub string) error
	StartSubscription(ctx context.Context, subName string, sub []string) error
}

Collector defines the interfaces for the collector

type DeviationServer

type DeviationServer struct {
	Targets map[string]*Target
	// contains filtered or unexported fields
}

DeviationServer contains the device driver information

func NewDeviationServer

func NewDeviationServer(opts ...Option) *DeviationServer

NewDeviationServer function defines a new Deviation Server

func (*DeviationServer) HandleTargetUpdate

func (d *DeviationServer) HandleTargetUpdate(ctx context.Context, tu TargetUpdate) error

HandleTargetUpdate supports updates of a Target

func (*DeviationServer) StartTargetChangeHandler

func (d *DeviationServer) StartTargetChangeHandler()

StartTargetChangeHandler changes to targets, targets can be deleted or created this function handles the changes to the targets

type DeviceCollectorOption

type DeviceCollectorOption func(*GNMICollector)

DeviceCollectorOption can be used to manipulate Options.

func WithDeviceCollectorLogger

func WithDeviceCollectorLogger(log logging.Logger) DeviceCollectorOption

WithDeviceCollectorLogger specifies how the collector logs messages.

type GNMICollector

type GNMICollector struct {
	TargetReceiveBuffer uint
	RetryTimer          time.Duration
	Target              *target.Target
	//targetSubRespChan   chan *collector.SubscribeResponse
	//targetSubErrChan    chan *collector.TargetError
	Subscriptions map[string]*Subscription
	Mutex         sync.RWMutex
	// contains filtered or unexported fields
}

GNMICollector defines the parameters for the collector

func NewGNMICollector

func NewGNMICollector(t *target.Target, opts ...DeviceCollectorOption) *GNMICollector

NewGNMICollector creates a new GNMI collector

func (*GNMICollector) GetSubscription

func (c *GNMICollector) GetSubscription(subName string) bool

GetSubscription returns a bool based on a subscription name

func (*GNMICollector) Lock

func (c *GNMICollector) Lock()

Lock locks a gnmi collector

func (*GNMICollector) StartSubscription

func (c *GNMICollector) StartSubscription(dctx context.Context, target, subName string, paths []*gnmi.Path) error

StartSubscription starts a subscription

func (*GNMICollector) StopSubscription

func (c *GNMICollector) StopSubscription(ctx context.Context, sub string) error

StopSubscription stops a subscription

func (*GNMICollector) Unlock

func (c *GNMICollector) Unlock()

Unlock unlocks a gnmi collector

type Option

type Option func(d *DeviationServer)

Option is a function to initialize the options

func WithEventChannels

func WithEventChannels(e map[string]chan event.GenericEvent) Option

WithEventChannels initializes the deviation server with event channels

func WithLogging

func WithLogging(l logging.Logger) Option

WithLogging initializes the deviation server with logging info

func WithStopChannel

func WithStopChannel(stopCh chan struct{}) Option

WithStopChannel initializes the deviation server with stop channel info

func WithTargetUpdateChannel

func WithTargetUpdateChannel(tu chan TargetUpdate) Option

WithTargetUpdateChannel initializes the deviation server with target update channels

type Subscription

type Subscription struct {
	StopCh   chan bool
	CancelFn context.CancelFunc
}

Subscription defines the parameters for the subscription

type Target

type Target struct {
	Config *types.TargetConfig
	Target *target.Target
	StopCh chan struct{}

	Collector *GNMICollector
	// contains filtered or unexported fields
}

Target defines the parameters for a Target

func (*Target) ReconcileOnChange

func (t *Target) ReconcileOnChange(resp *gnmi.SubscribeResponse) error

ReconcileOnChange reconciles an on change update

func (*Target) StartGnmiSubscriptionHandler

func (t *Target) StartGnmiSubscriptionHandler(ctx context.Context)

StartGnmiSubscriptionHandler starts gnmi subscription

type TargetAction

type TargetAction string

A TargetAction represents an action on a target

const (
	// start
	TargetAdd TargetAction = "target added"
	// stop
	TargetDelete TargetAction = "target deleted"
)

Condition Kinds.

type TargetUpdate

type TargetUpdate struct {
	Name         string
	Action       TargetAction
	TargetConfig *types.TargetConfig
}

TargetUpdate identifies the update actions on the target

Jump to

Keyboard shortcuts

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