connections

package
v0.12.0 Latest Latest
Warning

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

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

Documentation

Overview

Package connections provides the connection manager that forms the transport connection to gNMI targets and initiates gNMI RPC calls.

The ConnectionManager listens for TargetConnectionControl messages on the TargetControlChan and will perform the corresponding connects and disconnects for Insert and Remove, respectively. When an Insert is received the ConnectionManager will attempt to connect to the target if there is a connection slot available. The number of connection slots is configurable with the TargetLimit configuration parameter. If clustering is enabled the connection manager will attempt to acquire a lock for each target before making the connection. Locking will not be attempted if there are no connection slots available. Targets present in the Insert field will disconnect and overwrite existing targets with the same name, if the target configuration has changed.

The ConnectionManager accepts target configurations that follow the target.proto found here: https://github.com/openconfig/gnmi/blob/master/proto/target/target.proto The ConnectionManager additionally supports some per-target meta configuration options:

NoTLS	- Set this field to disable TLS for the target. If client TLS credentials
		  are not provided this field will have no effect.
NoLock	- Set this field to disable locking for the target. If clustering is not
		  enabled this field will have no effect.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTargetLockPath

func MakeTargetLockPath(prefix string, target string) string

Types

type ConnectionManager

type ConnectionManager interface {
	// Cache returns the *cache.Cache that contains gNMI Notifications.
	Cache() *cache.Cache
	// Forwardable returns true if this instance of the ConnectionManager
	// holds the lock for a non-cluster member connection for the named target.
	Forwardable(target string) bool
	// Start will start the loop to listen for TargetConnectionControl messages
	// on TargetControlChan.
	Start() error
	// TargetControlChan returns an input channel for TargetConnectionControl
	// messages.
	TargetControlChan() chan<- *TargetConnectionControl
}

ConnectionManager provides an interface for connecting/disconnecting to/from gNMI targets and forwards updates to a gNMI cache. Start must be called to start listening for changes on the TargetControlChan.

type ConnectionState added in v0.7.0

type ConnectionState struct {
	ConnectionLockAcquired bool
	// contains filtered or unexported fields
}

ConnectionState makes the calls to connect a target, tracks any associated connection state, and is the container for the target's cache data. It is created once for every device and used as a closure parameter by ProtoHandler.

func (*ConnectionState) Equal added in v0.7.0

func (t *ConnectionState) Equal(other *targetpb.Target) bool

Equal returns true if the target config is different than the target config for this ConnectionState instance.

func (*ConnectionState) InitializeMetrics added in v0.7.0

func (t *ConnectionState) InitializeMetrics()

func (*ConnectionState) Seen added in v0.7.0

func (t *ConnectionState) Seen(target string) bool

Seen returns true if the named target has been seen on this connection.

type TargetConnectionControl

type TargetConnectionControl struct {
	// Insert will insert and connect all of the named target configs. If a config with the same name
	// already exists it will be overwritten and the target reconnected if the new config is different
	// from the old one.
	Insert *targetpb.Configuration
	// Remove will remove and disconnect from all of the named targets.
	Remove []string
}

TargetConnectionControl messages are used to insert/update and remove targets in the ConnectionManager via the TargetControlChan channel.

func (*TargetConnectionControl) InsertCount

func (t *TargetConnectionControl) InsertCount() int

InsertCount is the number of targets in the Insert field, if Insert is not nil.

func (*TargetConnectionControl) RemoveCount

func (t *TargetConnectionControl) RemoveCount() int

RemoveCount is the number of targets in the Remove field, if Remove is not nil.

type ZookeeperConnectionManager added in v0.7.0

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

func NewZookeeperConnectionManagerDefault added in v0.7.0

func NewZookeeperConnectionManagerDefault(config *configuration.GatewayConfig, zkConn *zk.Conn, zkEvents <-chan zk.Event) (*ZookeeperConnectionManager, error)

NewZookeeperConnectionManagerDefault creates a new ConnectionManager with an empty *cache.Cache. Locking will be enabled if zkConn is not nil.

func (*ZookeeperConnectionManager) Cache added in v0.7.0

func (*ZookeeperConnectionManager) Forwardable added in v0.7.0

func (c *ZookeeperConnectionManager) Forwardable(target string) bool

Forwardable returns true if Notifications from the named target can be forwarded to Exporters.

func (*ZookeeperConnectionManager) ReloadTargets added in v0.7.0

func (c *ZookeeperConnectionManager) ReloadTargets()

ReloadTargets is a blocking loop to listen for target configurations from the TargetControlChan and handles connects/reconnects and disconnects to targets.

func (*ZookeeperConnectionManager) Start added in v0.7.0

func (c *ZookeeperConnectionManager) Start() error

func (*ZookeeperConnectionManager) TargetControlChan added in v0.7.0

func (c *ZookeeperConnectionManager) TargetControlChan() chan<- *TargetConnectionControl

Jump to

Keyboard shortcuts

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