proxy

package
v14.2.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package importsrv receives metrics over gRPC and sends them to workers.

The Server wraps a grpc.Server, and implements the forwardrpc.Forward service. It receives batches of metrics, then hashes them to a specific "MetricIngester" and forwards them on.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricIngester

type MetricIngester interface {
	IngestMetrics([]*metricpb.Metric)
}

MetricIngester reads metrics from protobufs

type Option

type Option func(*options)

Option is returned by functions that serve as options to New, like "With..."

func WithTraceClient

func WithTraceClient(c *trace.Client) Option

WithTraceClient sets the trace client for the server. Otherwise it uses trace.DefaultClient.

type Server

type Server struct {
	*grpc.Server
	// contains filtered or unexported fields
}

Server wraps a gRPC server and implements the forwardrpc.Forward service. It reads a list of metrics, and based on the provided key chooses a MetricIngester to send it to. A unique metric (name, tags, and type) should always be routed to the same MetricIngester.

func New

func New(address string, metricOuts []MetricIngester, logger *logrus.Entry, opts ...Option) *Server

New creates an unstarted Server with the input MetricIngester's to send output to.

func (*Server) Name

func (s *Server) Name() string

func (*Server) SendMetrics

func (s *Server) SendMetrics(ctx context.Context, mlist *forwardrpc.MetricList) (*empty.Empty, error)

SendMetrics takes a list of metrics and hashes each one (based on the metric key) to a specific metric ingester.

func (*Server) SendMetricsV2

func (s *Server) SendMetricsV2(
	server forwardrpc.Forward_SendMetricsV2Server,
) error

func (*Server) Start

func (s *Server) Start(ingest sources.Ingest) error

Start starts a gRPC listener on the specified address and blocks while listening for requests. If listening is interrupted by some means other than Stop or GracefulStop being called, it returns a non-nil error.

TODO this doesn't handle SIGUSR2 and SIGHUP on it's own, unlike HTTPServe As long as both are running this is actually fine, as Start will stop the gRPC server when the HTTP one exits. When running just gRPC however, the signal handling won't work.

func (*Server) Stop

func (s *Server) Stop()

Try to perform a graceful stop of the gRPC server. If it takes more than 10 seconds, timeout and force-stop.

Jump to

Keyboard shortcuts

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