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 ¶
- func InvokeAndSave[T proto.Message, S proto.Message](ctx context.Context, mgr *AttrMgr, rpc func(context.Context, T) (S, error), ...) (S, error)
- type AttrMgr
- func (mgr *AttrMgr) GetType(id string) saipb.ObjectType
- func (mgr *AttrMgr) Interceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
- func (mgr *AttrMgr) NextID() uint64
- func (mgr *AttrMgr) PopulateAllAttributes(id string, msg proto.Message) (rerr error)
- func (mgr *AttrMgr) PopulateAttributes(req, resp proto.Message) error
- func (mgr *AttrMgr) Reset()
- func (mgr *AttrMgr) SetType(id string, t saipb.ObjectType)
- func (mgr *AttrMgr) StoreAttributes(id uint64, msg proto.Message)
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 (*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) PopulateAllAttributes ¶
PopulateAllAttributes retrieves all attributes for an object. Supported message types FooAttribute, CreateFooRequest, SetFooRequest.
func (*AttrMgr) PopulateAttributes ¶
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 ¶
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.