client

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxRetries         int     = 2
	DefaultBackoffMinDelay    int     = 4
	DefaultBackoffMaxDelay    int     = 60
	DefaultBackoffDelayFactor float64 = 3
	GnmiTimeout                       = 15 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Devices map[string]*Device
	// Reuse connection
	ReuseConnection bool
	// Maximum number of retries
	MaxRetries int
	// Minimum delay between two retries
	BackoffMinDelay int
	// Maximum delay between two retries
	BackoffMaxDelay int
	// Backoff delay factor
	BackoffDelayFactor float64
}

func NewClient

func NewClient(reuseConnection bool) Client

func (*Client) AddTarget

func (c *Client) AddTarget(ctx context.Context, device, host, username, password, certificate, key, caCertificate string, verifyCertificate, Tls bool) error

func (*Client) Backoff

func (c *Client) Backoff(ctx context.Context, attempts int) bool

Backoff waits following an exponential backoff algorithm

func (*Client) Get

func (c *Client) Get(ctx context.Context, device, path string) (*gnmi.GetResponse, error)

func (*Client) Set

func (c *Client) Set(ctx context.Context, device string, operations ...SetOperation) (*gnmi.SetResponse, error)

type Device

type Device struct {
	SetMutex *sync.Mutex
	Target   *target.Target
}

type SetOperation

type SetOperation struct {
	Path      string
	Body      string
	Operation SetOperationType
}

type SetOperationType

type SetOperationType string
const (
	Update  SetOperationType = "update"
	Replace SetOperationType = "replace"
	Delete  SetOperationType = "delete"
)

Jump to

Keyboard shortcuts

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