channel

package
v2.17.0+incompatible Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package channel contains protocol details of two-way communication channel between pmm-managed and pmm-agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentRequest

type AgentRequest struct {
	ID      uint32
	Payload agentpb.AgentRequestPayload
}

AgentRequest represents an request from agent. It is similar to agentpb.AgentMessage except it can contain only requests, and the payload is already unwrapped (XXX instead of AgentMessage_XXX).

type Channel

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

Channel encapsulates two-way communication channel between pmm-managed and pmm-agent.

All exported methods are thread-safe.

func New

func New(stream agentpb.Agent_ConnectServer) *Channel

New creates new two-way communication channel with given stream.

Stream should not be used by the caller after channel is created.

func (*Channel) Metrics

func (c *Channel) Metrics() *Metrics

Metrics returns current channel metrics.

func (*Channel) Requests

func (c *Channel) Requests() <-chan *AgentRequest

Requests returns a channel for incoming requests. It must be read. It is closed on any error (see Wait).

func (*Channel) Send

func (c *Channel) Send(resp *ServerResponse)

Send sends message to pmm-managed. It is no-op once channel is closed (see Wait).

func (*Channel) SendAndWaitResponse

func (c *Channel) SendAndWaitResponse(payload agentpb.ServerRequestPayload) agentpb.AgentResponsePayload

SendAndWaitResponse sends request to pmm-managed, blocks until response is available, and returns it. Response will be nil if channel is closed. It is no-op once channel is closed (see Wait).

func (*Channel) Wait

func (c *Channel) Wait() error

Wait blocks until channel is closed and returns the reason why it was closed.

When Wait returns, underlying gRPC connection should be terminated to prevent goroutine leak.

type Metrics

type Metrics struct {
	Sent      float64 // a total number of messages sent to pmm-agent
	Recv      float64 // a total number of messages received from pmm-agent
	Responses float64 // the current length of the response queue
	Requests  float64 // the current length of the request queue
}

Metrics represents useful channel metrics.

type ServerResponse

type ServerResponse struct {
	ID      uint32
	Payload agentpb.ServerResponsePayload
}

ServerResponse represents server's response. It is similar to agentpb.ServerMessage except it can contain only responses, and the payload is already unwrapped (XXX instead of ServerMessage_XXX).

Jump to

Keyboard shortcuts

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