grpcutils

package
v1.14.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: Apache-2.0 Imports: 17 Imported by: 46

Documentation

Overview

Package grpcutils - provides a simple ListenAndServe for grpc

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressToURL

func AddressToURL(addr net.Addr) *url.URL

AddressToURL - convert net.Addr to a proper URL object

func ListenAndServe

func ListenAndServe(ctx context.Context, address *url.URL, server *grpc.Server) <-chan error

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

func NetworkAddressToURL(network, address string) *url.URL

NetworkAddressToURL - convert a network + address to proper URL object

func PassTraceToOutgoing

func PassTraceToOutgoing(ctx context.Context) context.Context

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

func TargetToNetAddr(target string) (network, addr string)

TargetToNetAddr returns the network and address from a GRPC target

func TargetToURL

func TargetToURL(address string) *url.URL

TargetToURL - convert target to a proper URL object

func URLToTarget

func URLToTarget(u *url.URL) (target string)

URLToTarget - convert *net.URL to acceptable grpc target value.

func UnwrapCode

func UnwrapCode(err error) codes.Code

UnwrapCode searches grpc status Code within the error

func WithTrace

func WithTrace(ctx context.Context, state TraceState) context.Context

WithTrace - enable/disable traces for outgoing context

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

Jump to

Keyboard shortcuts

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