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 is inferred from the flag name.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of Plugin.
Functions ¶
Types ¶
type Option ¶ added in v1.5.0
type Option func(*Plugin)
Option is a function that can be used in NewPlugin to customize Plugin.
type Plugin ¶
type Plugin struct { infra.PluginName // 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 NewPlugin ¶ added in v1.5.0
NewPlugin creates a new Plugin with the provided Options.
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 return the microservice label associated with this Agent // instance. GetAgentLabel() string // GetAgentPrefix returns the string that is supposed to be used // as the key prefix for the configuration "subtree" of the current Agent // instance (e.g. in ETCD). GetAgentPrefix() string // GetDifferentAgentPrefix returns the key prefix used by (another) Agent // instance from microservice labelled as <microserviceLabel>. GetDifferentAgentPrefix(microserviceLabel string) string // GetAllAgentsPrefix returns the part of the key prefix common to all // prefixes of all agents. GetAllAgentsPrefix() string }
ReaderAPI allows to read microservice label and key prefix associated with this Agent instance. The key prefix is supposed to be prepended to all keys used to store/read data in any key-value datastore. The intent is to give a common prefix to all keys used by a single agent. Furthermore, different agents have different prefixes assigned, hence there is no overlap of key spaces in-between agents.