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
- Variables
- type PiServer
- func (s *PiServer) GetDigit(ctx context.Context, in *generated.GetDigitRequest) (*generated.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, error)
- type PiServerOption
- func WithAnnotations(annotations map[string]string) PiServerOption
- func WithCache(cache cachepkg.Cache) PiServerOption
- func WithGRPCServerTransportCredentials(serverCredentials credentials.TransportCredentials) PiServerOption
- func WithLogger(logger logr.Logger) PiServerOption
- func WithRestClientAuthority(restClientAuthority string) PiServerOption
- func WithRestClientGRPCTransportCredentials(restClientGRPCCredentials credentials.TransportCredentials) PiServerOption
- func WithTags(tags []string) PiServerOption
Constants ¶
const (
// The default name to use when using OpenTelemetry components.
OpenTelemetryPackageIdentifier = "pkg.server"
)
Variables ¶
var ErrIndexTooLarge = fmt.Errorf("index is too large, must be <= %d", math.MaxInt64)
Functions ¶
This section is empty.
Types ¶
type PiServer ¶
type PiServer struct { generated.UnimplementedPiServiceServer // contains filtered or unexported fields }
func NewPiServer ¶
func NewPiServer(options ...PiServerOption) (*PiServer, error)
Create a new piServer and apply any options.
func (*PiServer) GetDigit ¶
func (s *PiServer) GetDigit(ctx context.Context, in *generated.GetDigitRequest) (*generated.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)
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, error)
Create a new xds.GRPCServer that is ready to be attached to a net.Listener.
type PiServerOption ¶
type PiServerOption func(*PiServer)
Defines the function signature for PiServer options.
func WithAnnotations ¶
func WithAnnotations(annotations map[string]string) PiServerOption
Add the key-value annotations to the server's metadata.
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 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 WithTags ¶
func WithTags(tags []string) PiServerOption
Add the string tags to the server's metadata.