Help us shape the future of Go! Take the 2026 Go Developer Survey

manager

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package manager provides functions to start or stop monitoring of a target.

Index

Constants

View Source
const (
	// Address is deprecated, proxies should support multiple addresses via the
	// Addresses metadata key.
	Address   = "address"
	Addresses = "addresses"
	Password  = "password"
	Target    = "target"
	Username  = "username"
)

gRPC metadata keys.

View Source
const (
	// AddrSeparator delimits the chain of addresses used to connect to a target.
	AddrSeparator = ";"
)

Variables

View Source
var (
	// ErrPending indicates a pending subscription attempt for the target exists.
	ErrPending = errors.New("subscription already pending")

	// RetryBaseDelay is the initial retry interval for target connections.
	RetryBaseDelay = time.Second
	// RetryMaxDelay caps the retry interval for target connections.
	RetryMaxDelay = time.Minute
	// RetryRandomization is the randomization factor applied to the retry
	// interval.
	RetryRandomization = 0.5
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Connect will be invoked when a target connects.
	Connect func(string)
	// Credentials is an optional client used to lookup passwords for targets
	// with a specified username and password ID.
	Credentials CredentialsClient
	// Reset will be invoked when a target disconnects.
	Reset func(string)
	// Sync will be invoked in response to gNMI sync updates.
	Sync func(string)
	// Timeout defines the optional duration to wait for a gRPC dial.
	Timeout time.Duration
	// ReceiveTimeout defines the optional duration to wait for receiving from
	// a target. 0 means timeout is disabled.
	ReceiveTimeout time.Duration
	// Update will be invoked in response to gNMI updates.
	Update func(string, *gpb.Notification)
	// ConnectionManager is used to create gRPC connections.
	ConnectionManager ConnectionManager
	// ConnectError records connecting errors from subscribe connections.
	ConnectError func(string, error)
	// MonitorError handles errors from subscribe connections.
	MonitorError func(string, error)
}

Config is used by Manager to handle updates.

type ConnectionManager

type ConnectionManager interface {
	Connection(ctx context.Context, addr, dialer string) (conn *grpc.ClientConn, done func(), err error)
}

ConnectionManager defines a function to create a *grpc.ClientConn along with a done function that will be called when the returned connection handle is unused.

type CredentialsClient

type CredentialsClient interface {
	Lookup(ctx context.Context, key string) (string, error)
}

CredentialsClient is an interface for credentials lookup.

type Manager

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

Manager provides functionality for making gNMI subscriptions to targets and handling updates.

func NewManager

func NewManager(cfg Config) (*Manager, error)

NewManager returns a new target Manager.

func (*Manager) Add

func (m *Manager) Add(name string, t *tpb.Target, sr *gpb.SubscribeRequest) error

Add adds the target to Manager and starts a streaming subscription that continues until Remove is called. Failed subscriptions are retried using exponential backoff.

After Add returns successfully, re-adding a target returns an error, unless first removed.

func (*Manager) Reconnect

func (m *Manager) Reconnect(name string) error

Reconnect triggers a reconnection for the specified target.

func (*Manager) Remove

func (m *Manager) Remove(name string) error

Remove stops the streaming connection to the target. Removing a target not added returns an error. Remove does not return until the subscription is completed and no further updates will occur.

Jump to

Keyboard shortcuts

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