grpc

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package grpc provides a Handler and client for agent gRPC connections.

Index

Constants

This section is empty.

Variables

View Source
var StatsCounters = []prometheus.CounterDefinition{
	{
		Name: []string{"grpc", "client", "request", "count"},
		Help: "Counts the number of gRPC requests made by the client agent to a Consul server.",
	},
	{
		Name: []string{"grpc", "server", "request", "count"},
		Help: "Counts the number of gRPC requests received by the server.",
	},
	{
		Name: []string{"grpc", "client", "connection", "count"},
		Help: "Counts the number of new gRPC connections opened by the client agent to a Consul server.",
	},
	{
		Name: []string{"grpc", "server", "connection", "count"},
		Help: "Counts the number of new gRPC connections received by the server.",
	},
	{
		Name: []string{"grpc", "server", "stream", "count"},
		Help: "Counts the number of new gRPC streams received by the server.",
	},
}
View Source
var StatsGauges = []prometheus.GaugeDefinition{
	{
		Name: []string{"grpc", "server", "connections"},
		Help: "Measures the number of active gRPC connections open on the server.",
	},
	{
		Name: []string{"grpc", "client", "connections"},
		Help: "Measures the number of active gRPC connections open from the client agent to any Consul servers.",
	},
	{
		Name: []string{"grpc", "server", "streams"},
		Help: "Measures the number of active gRPC streams handled by the server.",
	},
}

Functions

This section is empty.

Types

type ClientConnPool

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

ClientConnPool creates and stores a connection for each datacenter.

func NewClientConnPool

func NewClientConnPool(servers ServerLocator, tls TLSWrapper, useTLSForDC func(dc string) bool) *ClientConnPool

NewClientConnPool create new GRPC client pool to connect to servers using GRPC over RPC

func (*ClientConnPool) ClientConn

func (c *ClientConnPool) ClientConn(datacenter string) (*grpc.ClientConn, error)

ClientConn returns a grpc.ClientConn for the datacenter. If there are no existing connections in the pool, a new one will be created, stored in the pool, then returned.

type Handler

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

Handler implements a handler for the rpc server listener, and the agent.Component interface for managing the lifecycle of the grpc.Server.

func NewHandler

func NewHandler(addr net.Addr, register func(server *grpc.Server)) *Handler

NewHandler returns a gRPC server that accepts connections from Handle(conn). The register function will be called with the grpc.Server to register gRPC services with the server.

func (*Handler) Handle

func (h *Handler) Handle(conn net.Conn)

Handle the connection by sending it to a channel for the grpc.Server to receive.

func (*Handler) Run

func (h *Handler) Run() error

func (*Handler) Shutdown

func (h *Handler) Shutdown() error

type Logger

type Logger interface {
	Error(string, ...interface{})
}

type NoOpHandler

type NoOpHandler struct {
	Logger Logger
}

NoOpHandler implements the same methods as Handler, but performs no handling. It may be used in place of Handler to disable the grpc server.

func (NoOpHandler) Handle

func (h NoOpHandler) Handle(conn net.Conn)

func (NoOpHandler) Run

func (h NoOpHandler) Run() error

func (NoOpHandler) Shutdown

func (h NoOpHandler) Shutdown() error

type ServerLocator

type ServerLocator interface {
	// ServerForAddr is used to look up server metadata from an address.
	ServerForAddr(addr string) (*metadata.Server, error)
	// Authority returns the target authority to use to dial the server. This is primarily
	// needed for testing multiple agents in parallel, because gRPC requires the
	// resolver to be registered globally.
	Authority() string
}

type TLSWrapper

type TLSWrapper func(dc string, conn net.Conn) (net.Conn, error)

TLSWrapper wraps a non-TLS connection and returns a connection with TLS enabled.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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