cache

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ReadMode_Once           = "once"
	ReadMode_StreamOnChange = "stream_on_change"
	ReadMode_StreamSample   = "stream_sample"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Write inserts the proto.Message (SubscribeResponse) into the cache under a subscription called `sub`
	Write(ctx context.Context, sub string, m proto.Message)
	// ReadAll, reads entries from the local cache, return the entries grouped by subscription name.
	ReadAll() (map[string][]*gnmi.Notification, error)
	// Read, reads a single path value from the cache filtering by subscription and target name
	Read(sub, target string, p *gnmi.Path) (map[string][]*gnmi.Notification, error)
	// Subscribes to the local cache and returns the notification over a channel
	Subscribe(ctx context.Context, so *ReadOpts) chan *Notification
	// Stops the cache
	Stop()
	// DeleteTarget deletes the target from the cache by name
	DeleteTarget(name string)
	// SetLogger sets a logger for the cache
	SetLogger(l *log.Logger)
}

func New

func New(c *Config, opts ...Option) (Cache, error)

type CacheType

type CacheType string

type Config

type Config struct {
	Type       CacheType     `mapstructure:"type,omitempty" json:"type,omitempty"`
	Address    string        `mapstructure:"address,omitempty" json:"address,omitempty"`
	Timeout    time.Duration `mapstructure:"timeout,omitempty" json:"timeout,omitempty"`
	Expiration time.Duration `mapstructure:"expiration,omitempty" json:"expiration,omitempty"`
	Debug      bool          `mapstructure:"debug,omitempty" json:"debug,omitempty"`
	// NATS, JS and Redis cfg options
	Username string `mapstructure:"username,omitempty" json:"username,omitempty"`
	Password string `mapstructure:"password,omitempty" json:"password,omitempty"`

	// JS cfg options
	MaxBytes               int64         `mapstructure:"max-bytes,omitempty" json:"max-bytes,omitempty"`
	MaxMsgsPerSubscription int64         `mapstructure:"max-msgs-per-subscription,omitempty" json:"max-msgs-per-subscription,omitempty"`
	FetchBatchSize         int           `mapstructure:"fetch-batch-size,omitempty" json:"fetch-batch-size,omitempty"`
	FetchWaitTime          time.Duration `mapstructure:"fetch-wait-time,omitempty" json:"fetch-wait-time,omitempty"`
}

type Notification

type Notification struct {
	Name         string
	Notification *gnmi.Notification
	Err          error
}

type Option

type Option func(Cache)

func WithLogger

func WithLogger(logger *log.Logger) Option

type ReadOpts

type ReadOpts struct {
	Subscription      string
	Target            string
	Paths             []*gnmi.Path
	Mode              string
	SampleInterval    time.Duration
	HeartbeatInterval time.Duration
	SuppressRedundant bool
	UpdatesOnly       bool
	OverrideTS        bool
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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