Documentation ¶
Overview ¶
Package servicelabel provides support for creating/retrieving an identifier (a service label) for a CN-Infra based app.
p := serviceLabel.Plugin{} // initialization plugin handled by agent core
To retrieve service label of the VNF instance, run:
label = p.GetAgentLabel()
To retrieve prefix that can be used to access configuration of the VNF instance in key-value datastore, run:
prefix = p.GetAgentPrefix()
To retrieve prefix for a different VNF instance, run:
otherPrefix = p.GetDifferentAgentPrefix(differentLabel)
To retrieve prefix that identifies configuration of all instances:
allInstances = p.GetAllAgentsPrefix()
Index ¶
Constants ¶
const MicroserviceLabelEnvVar = "MICROSERVICE_LABEL"
MicroserviceLabelEnvVar label this is inferred from the flag name
Variables ¶
This section is empty.
Functions ¶
func GetAllAgentsPrefix ¶
func GetAllAgentsPrefix() string
GetAllAgentsPrefix returns the string that is supposed to be used as the prefix for configuration subtree of the particular VPP Agent instance (e.g. in ETCD).
func GetDifferentAgentPrefix ¶
GetDifferentAgentPrefix returns the string that is supposed to be used as the prefix for configuration "subtree" of the particular VPP Agent instance (e.g. in ETCD).
Types ¶
type Plugin ¶
type Plugin struct { // MicroserviceLabel identifies particular VNF. // Used primarily as a key prefix to ETCD data store. MicroserviceLabel string }
Plugin exposes the service label(i.e. the string used to identify the particular VNF) to the other plugins.
func OfDifferentAgent ¶ added in v1.0.3
OfDifferentAgent sets micorserivce label and returns new instance of Plugin. It is meant for watching DB by prefix of different agent. You can pass/inject instance of this plugin for example to kvdbsync.
func (*Plugin) GetAgentLabel ¶
GetAgentLabel returns string that is supposed to be used to distinguish (ETCD) key prefixes for particular VNF (particular VPP Agent configuration)
func (*Plugin) GetAgentPrefix ¶
GetAgentPrefix returns the string that is supposed to be used as the prefix for configuration of current MicroserviceLabel "subtree" of the particular VPP Agent instance (e.g. in ETCD).
func (*Plugin) GetAllAgentsPrefix ¶
GetAllAgentsPrefix returns the string that is supposed to be used as the prefix for configuration subtree of the particular VPP Agent instance (e.g. in ETCD).
func (*Plugin) GetDifferentAgentPrefix ¶
GetDifferentAgentPrefix returns the string that is supposed to be used as the prefix for configuration "subtree" of the particular VPP Agent instance (e.g. in ETCD).
type ReaderAPI ¶
type ReaderAPI interface { // GetAgentLabel returns string that is supposed to be used to distinguish // (ETCD) key prefixes for particular VNF (particular VPP Agent configuration) GetAgentLabel() string // GetAgentPrefix returns the string that is supposed to be used as the prefix for configuration of current // MicroserviceLabel "subtree" of the particular VPP Agent instance (e.g. in ETCD). GetAgentPrefix() string // GetDifferentAgentPrefix returns the string that is supposed to be used as the prefix for configuration // "subtree" of the particular VPP Agent instance (e.g. in ETCD). GetDifferentAgentPrefix(microserviceLabel string) string // GetAllAgentsPrefix returns the string that is supposed to be used as the prefix for configuration // subtree of the particular VPP Agent instance (e.g. in ETCD). GetAllAgentsPrefix() string }
ReaderAPI allows to read agent micorservice label with prefix. Reason for doing this is to have prefix for all keys of the agent.