client

package
v2.2.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalClient = NewClient(&txnFactory{local.DefaultRegistry})

LocalClient is global client for direct local access.

Functions

This section is empty.

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 interface {
	// KnownModels retrieves list of known modules.
	KnownModels() ([]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)
}

ConfigClient defines the client-side interface for config.

func NewClient

func NewClient(factory ProtoTxnFactory) ConfigClient

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

type ModelInfo

type ModelInfo = api.ModelInfo

type ProtoTxnFactory

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

ProtoTxnFactory defines interface for keyval transaction provider.

type StateItem

type StateItem = api.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

Items 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