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
- type PiServer
- func (s *PiServer) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
- func (s *PiServer) GetDigit(ctx context.Context, in *api.GetDigitRequest) (*api.GetDigitResponse, error)
- func (s *PiServer) NewGrpcServer() *grpc.Server
- func (s *PiServer) NewRestGatewayHandler(ctx context.Context, grpcAddress string) (http.Handler, error)
- func (s *PiServer) NewXDSServer() *xds.GRPCServer
- func (s *PiServer) Watch(in *grpc_health_v1.HealthCheckRequest, _ grpc_health_v1.Health_WatchServer) error
- type PiServerOption
- func WithCache(cache cachepkg.Cache) PiServerOption
- func WithGRPCServerTransportCredentials(serverCredentials credentials.TransportCredentials) PiServerOption
- func WithLogger(logger logr.Logger) PiServerOption
- func WithMetadata(metadata *api.GetDigitMetadata) PiServerOption
- func WithMeter(meter metric.Meter) PiServerOption
- func WithPrefix(prefix string) PiServerOption
- func WithRestClientAuthority(restClientAuthority string) PiServerOption
- func WithRestClientGRPCTransportCredentials(restClientGRPCCredentials credentials.TransportCredentials) PiServerOption
- func WithTracer(tracer trace.Tracer) PiServerOption
Constants ¶
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 ¶
func (s *PiServer) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Implement the gRPC health service Check method.
func (*PiServer) GetDigit ¶
func (s *PiServer) GetDigit(ctx context.Context, in *api.GetDigitRequest) (*api.GetDigitResponse, error)
Implement the PiService GetDigit RPC method.
func (*PiServer) NewGrpcServer ¶
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 ¶
func (s *PiServer) Watch(in *grpc_health_v1.HealthCheckRequest, _ grpc_health_v1.Health_WatchServer) error
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.