server

package
v2.0.0-rc6 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package server implements a gRPC server (and optional REST gateway) implementation that satisfies the PiServiceClient interface requirements, with optional OpenTelemetry metrics and traces.

Index

Constants

View Source
const (
	// The default name to use when registering OpenTelemetry components.
	DefaultOpenTelemetryServerName = "pkg.server"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PiServer

type PiServer struct {
	api.UnimplementedPiServiceServer
	// contains filtered or unexported fields
}

func NewPiServer

func NewPiServer(options ...PiServerOption) (*PiServer, error)

Create a new piServer and apply any options.

func (*PiServer) Check

Implement the gRPC health service Check method.

func (*PiServer) GetDigit

Implement the PiService GetDigit RPC method.

func (*PiServer) NewGrpcServer

func (s *PiServer) NewGrpcServer() *grpc.Server

Create a new grpc.Server that is ready to be attached to a net.Listener.

func (*PiServer) NewRestGatewayHandler

func (s *PiServer) NewRestGatewayHandler(ctx context.Context, grpcAddress string) (http.Handler, error)

Registers the gRPC services to the Create a new REST gateway handler that translates and forwards incoming REST requests to the specified gRPC endpoint address.

func (*PiServer) NewXDSServer

func (s *PiServer) NewXDSServer() *xds.GRPCServer

Create a new xds.GRPCServer that is ready to be attached to a net.Listener.

func (*PiServer) Watch

Satisfy the gRPC health service Watch method - always returns an Unimplemented error.

type PiServerOption

type PiServerOption func(*PiServer)

Defines the function signature for PiServer options.

func WithCache

func WithCache(cache cachepkg.Cache) PiServerOption

Use the Cache implementation to store BBPDigits results to avoid recalculation of a digit that has already been calculated.

func WithGRPCServerTransportCredentials

func WithGRPCServerTransportCredentials(serverCredentials credentials.TransportCredentials) PiServerOption

Set the TransportCredentials to use for Pi Service gRPC listener.

func WithLogger

func WithLogger(logger logr.Logger) PiServerOption

Use the supplied logger for the server and pi packages.

func WithMetadata

func WithMetadata(metadata *api.GetDigitMetadata) PiServerOption

Populate a metadata structure for this instance.

func WithMeter

func WithMeter(meter metric.Meter) PiServerOption

Add an OpenTelemetry metric meter implementation to the PiService server.

func WithPrefix

func WithPrefix(prefix string) PiServerOption

Set the prefix to use for OpenTelemetry metrics.

func WithRestClientAuthority

func WithRestClientAuthority(restClientAuthority string) PiServerOption

Set the authority string to use for REST-gRPC gateway calls.

func WithRestClientGRPCTransportCredentials

func WithRestClientGRPCTransportCredentials(restClientGRPCCredentials credentials.TransportCredentials) PiServerOption

Set the TransportCredentials to use for Pi Service REST-to-gRPC client.

func WithTracer

func WithTracer(tracer trace.Tracer) PiServerOption

Add an OpenTelemetry tracer implementation to the PiService server.

Jump to

Keyboard shortcuts

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