servicelabel

package
Version: v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 4 Imported by: 150

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

View Source
const MicroserviceLabelEnvVar = "MICROSERVICE_LABEL"

MicroserviceLabelEnvVar label is inferred from the flag name.

Variables

View Source
var DefaultPlugin = *NewPlugin()

DefaultPlugin is a default instance of Plugin.

Functions

func GetAllAgentsPrefix

func GetAllAgentsPrefix() string

GetAllAgentsPrefix returns the part of the key prefix common to all prefixes of all agents.

func GetDifferentAgentPrefix

func GetDifferentAgentPrefix(microserviceLabel string) string

GetDifferentAgentPrefix returns the key prefix used by (another) Agent instance from microservice labelled as <microserviceLabel>.

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.

func UseLabel added in v1.5.0

func UseLabel(label string) Option

UseLabel sets microservice label to given string

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

func NewPlugin(opts ...Option) *Plugin

NewPlugin creates a new Plugin with the provided Options.

func (*Plugin) Close

func (p *Plugin) Close() error

Close is called at plugin cleanup phase.

func (*Plugin) GetAgentLabel

func (p *Plugin) GetAgentLabel() string

GetAgentLabel returns string that is supposed to be used to distinguish (ETCD) key prefixes for particular VNF (particular VPP Agent configuration)

func (*Plugin) GetAgentPrefix

func (p *Plugin) GetAgentPrefix() 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).

func (*Plugin) GetAllAgentsPrefix

func (p *Plugin) 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 (*Plugin) GetDifferentAgentPrefix

func (p *Plugin) GetDifferentAgentPrefix(microserviceLabel string) 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).

func (*Plugin) Init

func (p *Plugin) Init() error

Init is called at plugin initialization.

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.

Jump to

Keyboard shortcuts

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