client

package
v0.0.0-...-865e90e Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	MessageName string
	Objects     []*Object
}

Change is a collection of configuration objects of the same protobuf message type.

type Client

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

Client is a client implementation of the Mesh Configuration Protocol (MCP). It is responsible for the following:

  • Maintaining the bidirectional grpc stream with the server. The stream will be reestablished on transient network failures. The provided grpc connection (mcpClient) is assumed to handle (re)dialing the server.
  • Handling all aspects of the MCP exchange for the supported message types, e.g. request/response, ACK/NACK, nonce, versioning,

- Decoding the received configuration updates and providing them to the user via a batched set of changes.

func New

func New(mcpClient mcp.AggregatedMeshConfigServiceClient, supportedMessageNames []string, updater Updater, id string, metadata map[string]string) *Client

New creates a new instance of the MCP client for the specified message types.

func (*Client) Run

func (c *Client) Run(ctx context.Context)

Run starts the run loop for request and receiving configuration updates from the server. This function blocks and should typically be run in a goroutine. The client will continue to attempt to re-establish the stream with the server indefinitely. The function exits when the provided context is canceled.

type Object

type Object struct {
	MessageName string
	Metadata    *mcp.Metadata
	Resource    proto.Message
	Version     string
}

Object contains a decoded versioned object with metadata received from the server.

type Updater

type Updater interface {
	// Update is invoked when the client receives new configuration updates
	// from the server. The caller should return an error if any of the provided
	// configuration resources are invalid or cannot be applied. The client will
	// propagate errors back to the server accordingly.
	Update(*Change) error
}

Updater provides configuration changes in batches of the same protobuf message type.

Jump to

Keyboard shortcuts

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