Documentation ¶
Index ¶
- Variables
- type Change
- type Client
- type MetricReporter
- type Object
- type RecentRequestInfo
- type StatsContext
- func (s *StatsContext) RecordRecvError(err error, code codes.Code)
- func (s *StatsContext) RecordRequestAck(typeURL string)
- func (s *StatsContext) RecordRequestNack(typeURL string, err error)
- func (s *StatsContext) RecordSendError(err error, code codes.Code)
- func (s *StatsContext) RecordStreamCreateSuccess()
- type Updater
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
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, supportedTypeURLs []string, updater Updater, id string, metadata map[string]string, reporter MetricReporter) *Client
New creates a new instance of the MCP client for the specified message types.
func (*Client) Run ¶
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.
func (*Client) SnapshotRequestInfo ¶
func (c *Client) SnapshotRequestInfo() []RecentRequestInfo
SnapshotRequestInfo returns a snapshot of the last known set of request results.
func (*Client) SupportedTypeURLs ¶
SupportedTypeURLs returns the TypeURLs that this client requests.
type MetricReporter ¶
type MetricReporter interface { RecordSendError(err error, code codes.Code) RecordRecvError(err error, code codes.Code) RecordRequestAck(typeURL string) RecordRequestNack(typeURL string, err error) RecordStreamCreateSuccess() }
MetricReporter is used to report metrics for an MCP client.
type RecentRequestInfo ¶
type RecentRequestInfo struct { Time time.Time Request *mcp.MeshConfigRequest }
RecentRequestInfo is metadata about a request that the client has sent.
func (RecentRequestInfo) Acked ¶
func (r RecentRequestInfo) Acked() bool
Acked indicates whether the message was an ack or not.
type StatsContext ¶
type StatsContext struct {
// contains filtered or unexported fields
}
StatsContext enables metric collection backed by OpenCensus.
func NewStatsContext ¶
func NewStatsContext(prefix string) *StatsContext
NewStatsContext creates a new context for recording metrics using OpenCensus. The specified prefix is prepended to all metric names and must be a non-empty string.
func (*StatsContext) RecordRecvError ¶
func (s *StatsContext) RecordRecvError(err error, code codes.Code)
RecordRecvError records an error during a network recv with its error string and code.
func (*StatsContext) RecordRequestAck ¶
func (s *StatsContext) RecordRequestAck(typeURL string)
RecordRequestAck records an ACK message for a type URL on a connection.
func (*StatsContext) RecordRequestNack ¶
func (s *StatsContext) RecordRequestNack(typeURL string, err error)
RecordRequestNack records a NACK message for a type URL on a connection.
func (*StatsContext) RecordSendError ¶
func (s *StatsContext) RecordSendError(err error, code codes.Code)
RecordSendError records an error during a network send with its error string and code.
func (*StatsContext) RecordStreamCreateSuccess ¶
func (s *StatsContext) RecordStreamCreateSuccess()
RecordStreamCreateSuccess records a successful stream connection.
type Updater ¶
type Updater interface { // Apply 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. Apply(*Change) error }
Updater provides configuration changes in batches of the same protobuf message type.