grpc

package
v0.0.0-...-53d8ad0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCertPool

func NewCertPool(ca string) (*x509.CertPool, error)

NewCertPool takes the path of a CA cert and attempts to parse the certificate, adding it to a CA pool if successful.

func NewClientTransportCreds

func NewClientTransportCreds(ca, crt, key string) (credentials.TransportCredentials, error)

NewClientTransportCreds creates gRPC Transport Credentials with a root CA configured.

func NewServerTransportCreds

func NewServerTransportCreds(ca, crt, key string) (credentials.TransportCredentials, error)

NewServerTransportCreds creates gRPC Transport Credentials with a client CA configured.

func NewTLSConfig

func NewTLSConfig(crt, key string) (*tls.Config, error)

NewTLSConfig takes the paths of a server cert/key and returns TLS transport credentials. TLS 1.3 is the minimum version.

func StreamInterceptor

func StreamInterceptor(service_id string) grpc.StreamServerInterceptor

StreamInterceptor instruments and logs information about gRPC stream calls.

func UnaryInterceptor

func UnaryInterceptor(service_id string) grpc.UnaryServerInterceptor

UnaryInterceptor instruments and logs information about gRPC unary calls.

Types

type Server

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

Server is a wrapper around a *grpc.Server. It provides helper functions for starting the server and registering services.

func NewServer

func NewServer(opts []grpc.ServerOption) *Server

func (*Server) RegisterService

func (s *Server) RegisterService(sd *grpc.ServiceDesc, svc interface{})

RegisterService registers a gRPC service to the underlying server.

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, port int) error

Server starts the *grpc.Server on a given port in a goroutine. It waits for the server's context to be done before gracefully shutting down.

func (*Server) Shutdown

func (s *Server) Shutdown()

type ServiceServer

type ServiceServer interface {
	RegisterService(sd *grpc.ServiceDesc, svc interface{})
	Serve(ctx context.Context, port int) error
	Shutdown()
}

Jump to

Keyboard shortcuts

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