Documentation
¶
Overview ¶
Package grpc implements helper functions to interact with grpc
Index ¶
- func AuthInterceptor(verifier verifierFunc) grpc_auth.AuthFunc
- func DoWithTimeout(f func() error, d time.Duration) error
- func GetDDAgentClient(ctx context.Context, ipcAddress string, cmdPort string, ...) (pb.AgentClient, error)
- func GetDDAgentSecureClient(ctx context.Context, ipcAddress string, cmdPort string, ...) (pb.AgentSecureClient, error)
- func NewBearerTokenAuth(token string) credentials.PerRPCCredentials
- func NewLogger() grpclog.LoggerV2
- func NewMockGrpcSecureServer(port string) (*grpc.Server, string, error)
- func NewMuxedGRPCServer(addr string, tlsConfig *tls.Config, grpcServer *grpc.Server, ...) *http.Server
- func StaticAuthInterceptor(token string) grpc_auth.AuthFunc
- func TimeoutHandlerFunc(httpHandler http.Handler, timeout time.Duration) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AuthInterceptor ¶
AuthInterceptor is a gRPC interceptor that extracts an auth token from the request headers, and validates it using the provided func.
func DoWithTimeout ¶
DoWithTimeout runs f and returns its error. If the deadline d elapses first, it returns a grpc DeadlineExceeded error instead.
func GetDDAgentClient ¶
func GetDDAgentClient(ctx context.Context, ipcAddress string, cmdPort string, opts ...grpc.DialOption) (pb.AgentClient, error)
GetDDAgentClient creates a pb.AgentClient for IPC with the main agent via gRPC. This call is blocking by default, so it is up to the caller to supply a context with appropriate timeout/cancel options
func GetDDAgentSecureClient ¶
func GetDDAgentSecureClient(ctx context.Context, ipcAddress string, cmdPort string, opts ...grpc.DialOption) (pb.AgentSecureClient, error)
GetDDAgentSecureClient creates a pb.AgentSecureClient for IPC with the main agent via gRPC. This call is blocking by default, so it is up to the caller to supply a context with appropriate timeout/cancel options
func NewBearerTokenAuth ¶ added in v0.61.0
func NewBearerTokenAuth(token string) credentials.PerRPCCredentials
NewBearerTokenAuth creates a set of per-RPC credentials that uses a bearer token for authentication/authorization.
This credentials implementation requires the connection to be secure (i.e. using TLS).
func NewLogger ¶
NewLogger returns a gRPC logger that logs to the Datadog logger instead of directly to stderr.
func NewMockGrpcSecureServer ¶ added in v0.61.0
NewMockGrpcSecureServer creates a new agent secure gRPC server for testing purposes.
func NewMuxedGRPCServer ¶
func NewMuxedGRPCServer(addr string, tlsConfig *tls.Config, grpcServer *grpc.Server, httpHandler http.Handler) *http.Server
NewMuxedGRPCServer returns an http.Server that multiplexes connections between a gRPC server and an HTTP handler.
func StaticAuthInterceptor ¶ added in v0.61.0
StaticAuthInterceptor is a gRPC interceptor that extracts an auth token from the request headers, and validates it using the given token.
func TimeoutHandlerFunc ¶
TimeoutHandlerFunc returns an HTTP handler that times out after a duration. This is useful for muxed gRPC servers where http.Server cannot have a timeout when handling streaming, long running connections.
Types ¶
This section is empty.