client

package
v3.4.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: Apache-2.0 Imports: 21 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

LocalClient is global client for direct local access. Updates and resyncs of this client use local.DefaultRegistry for propagating data to orchestrator.Dispatcher (going through watcher.Aggregator together with other data sources). However, data retrieval uses orchestrator.Dispatcher directly.

Functions

func DynamicConfigExport added in v3.3.0

func DynamicConfigExport(dynamicConfig *dynamicpb.Message) ([]proto.Message, error)

DynamicConfigExport exports from dynamic config the proto.Messages corresponding to known models that were given as input when dynamic config was created using NewDynamicConfig. This is a convenient method how to extract data for generic client usage (proto.Message instances) from value-filled dynamic config (i.e. after json/yaml loading into dynamic config).

func DynamicConfigGroupFieldNaming added in v3.3.0

func DynamicConfigGroupFieldNaming(modelDetail *models.ModelInfo) string

DynamicConfigGroupFieldNaming computes for given known model the naming of configuration group proto field containing the instances of given model inside the dynamic config describing the whole VPP-Agent configuration. The json name of the field is the same as proto name of field.

func DynamicConfigKnownModelFieldNaming added in v3.3.0

func DynamicConfigKnownModelFieldNaming(modelDetail *models.ModelInfo) (protoName, jsonName string)

DynamicConfigKnownModelFieldNaming compute for given known model the (proto and json) naming of proto field containing the instances of given model inside the dynamic config describing the whole VPP-Agent configuration.

func ExportDynamicConfigStructure added in v3.3.0

func ExportDynamicConfigStructure(dynamicConfig proto.Message) (string, error)

ExportDynamicConfigStructure is a debugging helper function revealing current structure of dynamic config. Debugging tools can't reveal that because dynamic config is dynamic proto message with no fields named by proto fields as it is in generated proto messages.

func ModelOptionFor added in v3.3.0

func ModelOptionFor(key string, options []*generic.ModelDetail_Option) (string, error)

ModelOptionFor extracts value for given model detail option key

func NewDynamicConfig added in v3.3.0

func NewDynamicConfig(knownModels []*models.ModelInfo) (*dynamicpb.Message, error)

NewDynamicConfig creates dynamically proto Message that contains all given configuration models(knowModels). This proto message(when all VPP-Agent models are given as input) is json/yaml compatible with configurator.Config. The configurator.Config config have all models hardcoded (generated from config proto model, but that model is hardcoded). Dynamic config can contain also custom 3rd party models and therefore can be used to import/export config data also for 3rd party models that are registered, but not part of VPP-Agent repository and therefore not know to hardcoded configurator.Config.

Types

type ChangeRequest

type ChangeRequest interface {
	// Update appends updates for given items to the request.
	Update(items ...proto.Message) ChangeRequest

	// Delete appends deletes for given items to the request.
	Delete(items ...proto.Message) ChangeRequest

	// Send sends the request.
	Send(ctx context.Context) error
}

ChangeRequest is interface for config change request.

type ConfigClient

type ConfigClient = GenericClient

ConfigClient ... Deprecated: use GenericClient instead

func NewClient

func NewClient(factory ProtoTxnFactory, dispatcher orchestrator.Dispatcher) ConfigClient

NewClient returns new instance that uses given registry for data propagation and dispatcher for data retrieval.

type GenericClient added in v3.2.0

type GenericClient interface {
	// KnownModels retrieves list of known modules.
	KnownModels(class string) ([]*ModelInfo, error)

	// ChangeRequest returns transaction for changing config.
	ChangeRequest() ChangeRequest

	// ResyncConfig overwrites existing config.
	ResyncConfig(items ...proto.Message) error

	// GetConfig retrieves current config into dsts.
	// TODO: return as list of config items
	GetConfig(dsts ...interface{}) error

	// DumpState dumps actual running state.
	DumpState() ([]*StateItem, error)
}

GenericClient is the client-side interface for generic handler.

type ModelInfo

type ModelInfo = models.ModelInfo

ModelInfo is just retyped models.ModelInfo for backward compatibility purpose Deprecated: use models.ModelInfo instead

type ProtoTxnFactory

type ProtoTxnFactory interface {
	NewTxn(resync bool) keyval.ProtoTxn
}

ProtoTxnFactory defines interface for keyval transaction provider.

type StateItem

type StateItem = generic.StateItem

type Txn

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

Txn is the

func NewTxn

func NewTxn(commitFunc func() error) *Txn

NewTxn

func (*Txn) Commit

func (t *Txn) Commit(ctx context.Context)

func (*Txn) Delete

func (t *Txn) Delete(item proto.Message)

func (*Txn) FindItem

func (t *Txn) FindItem(id string) (model proto.Message, found bool)

FindItem returns item with given ID from the request items. If the found is true the model with such ID is found and if the model is nil the item represents delete.

func (*Txn) ListItems

func (t *Txn) ListItems() map[string]proto.Message

ListItems returns map of items defined for the request, where key represents model ID and nil value represents delete. NOTE: Do not alter the returned map directly.

func (*Txn) RemoveItem

func (t *Txn) RemoveItem(model proto.Message)

RemoveItem removes an item from the transaction. This will revert any Update or Delete done for the item.

func (*Txn) Update

func (t *Txn) Update(item proto.Message)

Update updates

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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