Documentation ¶
Overview ¶
Package grpcutils - provides a simple ListenAndServe for grpc
Index ¶
- func AddressToURL(addr net.Addr) *url.URL
- func ListenAndServe(ctx context.Context, address *url.URL, server *grpc.Server) <-chan error
- func NetworkAddressToURL(network, address string) *url.URL
- func PassTraceToOutgoing(ctx context.Context) context.Context
- func RegisterHealthServices(s grpc.ServiceRegistrar, services ...interface{})
- func TargetToNetAddr(target string) (network, addr string)
- func TargetToURL(address string) *url.URL
- func URLToTarget(u *url.URL) (target string)
- func UnwrapCode(err error) codes.Code
- func WithTrace(ctx context.Context, state TraceState) context.Context
- type TraceState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressToURL ¶
AddressToURL - convert net.Addr to a proper URL object
func ListenAndServe ¶
ListenAndServe listens on address with server. Returns an chan err which will receive an error and then be closed in the event that server.Serve(listener) returns an error.
func NetworkAddressToURL ¶
NetworkAddressToURL - convert a network + address to proper URL object
func PassTraceToOutgoing ¶
PassTraceToOutgoing - passes trace state from incoming to outgoing context
func RegisterHealthServices ¶
func RegisterHealthServices(s grpc.ServiceRegistrar, services ...interface{})
RegisterHealthServices registers grpc health probe for each passed service
func TargetToNetAddr ¶
TargetToNetAddr returns the network and address from a GRPC target
func TargetToURL ¶
TargetToURL - convert target to a proper URL object
func URLToTarget ¶
URLToTarget - convert *net.URL to acceptable grpc target value.
func UnwrapCode ¶
UnwrapCode searches grpc status Code within the error
Types ¶
type TraceState ¶
type TraceState int
TraceState is a type that defines the state of the traces stored in grpc metadata
const ( // TraceUndefined - no state is defined TraceUndefined TraceState = iota // TraceOn - tracing is enabled TraceOn // TraceOff - tracing is disabled TraceOff )
func TraceFromContext ¶
func TraceFromContext(ctx context.Context) TraceState
TraceFromContext - checks if incoming metadata allows traces