attrmgr

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package attrmgr contains a SAI attribute key/value store. Each object has a set of attributes: a map of attribute id (enum value) to value (a number of different types). Attributes are set using Create and Set RPCs and retrieved using Get RPCs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvokeAndSave

func InvokeAndSave[T proto.Message, S proto.Message](ctx context.Context, mgr *AttrMgr, rpc func(context.Context, T) (S, error), req T) (S, error)

InvokeAndSave calls the RPC method and saves the attributes in the request and returns the RPC response. This is the same behavior as the Interceptor, except for invoking server methods directly (not using gRPC).

Types

type AttrMgr

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

AttrMgr stores and retrieve the SAI attributes.

func New

func New() *AttrMgr

New returns a new AttrMgr.

func (*AttrMgr) GetType

func (mgr *AttrMgr) GetType(id string) saipb.ObjectType

GetType returns the SAI type for the object.

func (*AttrMgr) Interceptor

func (mgr *AttrMgr) Interceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

Interceptor returns a gRPC interceptor that automatically store values set in requests and fills in responses with the stored values.

func (*AttrMgr) NextID

func (mgr *AttrMgr) NextID() uint64

NextID returns the next available object id.

func (*AttrMgr) PopulateAllAttributes

func (mgr *AttrMgr) PopulateAllAttributes(id string, msg proto.Message) (rerr error)

PopulateAllAttributes retrieves all attributes for an object. Supported message types FooAttribute, CreateFooRequest, SetFooRequest.

func (*AttrMgr) PopulateAttributes

func (mgr *AttrMgr) PopulateAttributes(req, resp proto.Message) error

populateAttributes fills the resp with the requests attributes. This must called with GetFooAttributeRequest and GetFooAttributeResponse message types.

func (*AttrMgr) Reset

func (mgr *AttrMgr) Reset()

Reset resets all fields attributes in the manager.

func (*AttrMgr) SetType

func (mgr *AttrMgr) SetType(id string, t saipb.ObjectType)

GetType returns the SAI type for the object.

func (*AttrMgr) StoreAttributes

func (mgr *AttrMgr) StoreAttributes(id uint64, msg proto.Message)

StoreAttributes stores all the attributes in the message. Note: for lists, a nil lists is an unset attribute, but a non-nil empty list is set. so querying a nil list returns an error, even though they look the same on the wire.

Jump to

Keyboard shortcuts

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