Documentation ¶
Index ¶
- func EmbedContext(ctx context.Context) (context.Context, error)
- func ExtractTransit(ctx context.Context) (context.Context, error)
- func MustDialOption(opt grpc.DialOption, err error) grpc.DialOption
- func WithMutualTLS(serverName, certFile, keyFile, caFile string) (grpc.DialOption, error)
- func WithTLS(certFile, serverNameOverride string) (grpc.DialOption, error)
- func WrapResolver(r spine.Resolver) grpc.Resolver
- type Client
- type Info
- type Server
- func (s *Server) ActivateMutualTLS(certFile, keyFile, caFile string)
- func (s *Server) ActivateTLS(certFile, keyFile string)
- func (s *Server) AppendStreamMiddleware(m StreamServerMiddleware)
- func (s *Server) AppendUnaryMiddleware(m UnaryServerMiddleware)
- func (s *Server) Drain()
- func (s *Server) Handle(f func(*grpc.Server))
- func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})
- func (s *Server) Serve(ctx context.Context, addr string) error
- func (s *Server) SetOptions(opts ...grpc.ServerOption)
- type StreamClientMiddleware
- type StreamHandler
- type StreamServerMiddleware
- type UnaryClientMiddleware
- type UnaryHandler
- type UnaryServerMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractTransit ¶
ExtractTransit extracts transit from ctx or creates a new one
func MustDialOption ¶
func MustDialOption(opt grpc.DialOption, err error) grpc.DialOption
MustDialOption panics if it receives an error
func WithMutualTLS ¶
func WithMutualTLS( serverName, certFile, keyFile, caFile string, ) (grpc.DialOption, error)
WithMutualTLS returns a dial option for the GRPC client that activates a mutual TLS authentication between the server and the client.
Types ¶
type Client ¶
type Client struct { // HTTP is the standard net/http client GRPC *grpc.ClientConn // PropagateContext tells whether the context should be propagated upstream // // This should be activated when the upstream endpoint is a SPINE service // or another SPINE-compatible service. The context can potentially leak // sensitive information, so do not activate it for services that you // don't trust. PropagateContext bool // contains filtered or unexported fields }
Client is a wrapper for the grpc client.
func (*Client) AppendStreamMiddleware ¶
func (c *Client) AppendStreamMiddleware(m StreamClientMiddleware)
func (*Client) AppendUnaryMiddleware ¶
func (c *Client) AppendUnaryMiddleware(m UnaryClientMiddleware)
type Info ¶
type Info struct { // FullMethod is the full RPC method string, i.e., /package.service/method. FullMethod string // StartTime is the time on which the request hast started StartTime time.Time }
Info contains information about a request
type Server ¶
A Server defines parameters for running a spine compatible GRPC server
func (*Server) ActivateMutualTLS ¶
ActivateMutualTLS activates TLS on this handler. That means only incoming TLS connections are allowed and clients must authenticate themselves to the server.
If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
func (*Server) ActivateTLS ¶
ActivateTLS activates TLS on this handler. That means only incoming TLS connections are allowed.
If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
Clients are not authenticated.
func (*Server) AppendStreamMiddleware ¶
func (s *Server) AppendStreamMiddleware(m StreamServerMiddleware)
AppendStreamMiddleware appends a stream middleware to the call chain
func (*Server) AppendUnaryMiddleware ¶
func (s *Server) AppendUnaryMiddleware(m UnaryServerMiddleware)
AppendUnaryMiddleware appends an unary middleware to the call chain
func (*Server) Handle ¶
Handle just injects the GRPC server to register a service. The function is called back only when Serve is called. This must be called before invoking Serve.
func (*Server) RegisterService ¶
func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})
RegisterService register a service and its implementation to the gRPC server. Called from the IDL generated code.
The function is called back only when Serve is called. This must be called before invoking Serve.
func (*Server) SetOptions ¶
func (s *Server) SetOptions(opts ...grpc.ServerOption)
SetOptions changes the handler options
type StreamClientMiddleware ¶
func OpenTracingStreamClientMiddleware ¶
func OpenTracingStreamClientMiddleware(spanOpts ...opentracing.StartSpanOption) StreamClientMiddleware
OpenTracingStreamClientMiddleware returns a StreamClientMiddleware that injects a child span into the gRPC metadata if a span is found within the given context.
type StreamHandler ¶
type StreamHandler func(srv interface{}, info *Info, ss grpc.ServerStream) error
type StreamServerMiddleware ¶
type StreamServerMiddleware func(next StreamHandler) StreamHandler
type UnaryClientMiddleware ¶
type UnaryClientMiddleware func(grpc.UnaryInvoker) grpc.UnaryInvoker
func OpenTracingUnaryClientMiddleware ¶
func OpenTracingUnaryClientMiddleware(spanOpts ...opentracing.StartSpanOption) UnaryClientMiddleware
OpenTracingUnaryClientMiddleware returns a UnaryClientMiddleware that injects a child span into the gRPC metadata if a span is found within the given context.
type UnaryHandler ¶
type UnaryServerMiddleware ¶
type UnaryServerMiddleware func(next UnaryHandler) UnaryHandler