Documentation
¶
Overview ¶
Package grpc implements helper functions to interact with grpc
Index ¶
- func AuthInterceptor(verifier verifierFunc) grpc_auth.AuthFunc
- func ClientOptionsWithMetrics(opts ...grpc.DialOption) []grpc.DialOption
- func CombinedStreamServerInterceptor(authInterceptor grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
- func CombinedUnaryServerInterceptor(authInterceptor grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
- func DoWithTimeout(f func() error, d time.Duration) error
- func GetDDAgentClient(ctx context.Context, ipcAddress string, cmdPort string, tlsConfig *tls.Config, ...) (pb.AgentClient, error)
- func GetDDAgentSecureClient(ctx context.Context, ipcAddress string, cmdPort string, tlsConfig *tls.Config, ...) (pb.AgentSecureClient, error)
- func NewBearerTokenAuth(token string) credentials.PerRPCCredentials
- func NewLogger() grpclog.LoggerV2
- func NewMockGrpcSecureServer(port string, authtoken string, serverTLSConfig *tls.Config) (*grpc.Server, error)
- func NewServerWithMetrics(opts ...grpc.ServerOption) *grpc.Server
- func ServerOptionsWithMetrics(opts ...grpc.ServerOption) []grpc.ServerOption
- func ServerOptionsWithMetricsAndAuth(authUnaryInterceptor grpc.UnaryServerInterceptor, ...) []grpc.ServerOption
- func StaticAuthInterceptor(token string) grpc_auth.AuthFunc
- func StreamClientInterceptor() grpc.StreamClientInterceptor
- func StreamServerInterceptor() grpc.StreamServerInterceptor
- func UnaryClientInterceptor() grpc.UnaryClientInterceptor
- func UnaryServerInterceptor() grpc.UnaryServerInterceptor
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 ClientOptionsWithMetrics ¶ added in v0.72.0
func ClientOptionsWithMetrics(opts ...grpc.DialOption) []grpc.DialOption
ClientOptionsWithMetrics returns gRPC client options with metrics interceptors
func CombinedStreamServerInterceptor ¶ added in v0.72.0
func CombinedStreamServerInterceptor(authInterceptor grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
CombinedStreamServerInterceptor creates a stream interceptor that combines metrics and auth
func CombinedUnaryServerInterceptor ¶ added in v0.72.0
func CombinedUnaryServerInterceptor(authInterceptor grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
CombinedUnaryServerInterceptor creates a unary interceptor that combines metrics and auth
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, tlsConfig *tls.Config, 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, tlsConfig *tls.Config, 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
func NewMockGrpcSecureServer(port string, authtoken string, serverTLSConfig *tls.Config) (*grpc.Server, error)
NewMockGrpcSecureServer creates a new agent secure gRPC server for testing purposes.
func NewServerWithMetrics ¶ added in v0.72.0
func NewServerWithMetrics(opts ...grpc.ServerOption) *grpc.Server
NewServerWithMetrics creates a new gRPC server with metrics interceptors
func ServerOptionsWithMetrics ¶ added in v0.72.0
func ServerOptionsWithMetrics(opts ...grpc.ServerOption) []grpc.ServerOption
ServerOptionsWithMetrics returns gRPC server options with metrics interceptors IMPORTANT: This function should be called BEFORE adding other interceptors to avoid conflicts. If you already have interceptors configured, you need to manually chain them or use the metrics interceptors directly in your server setup.
func ServerOptionsWithMetricsAndAuth ¶ added in v0.72.0
func ServerOptionsWithMetricsAndAuth(authUnaryInterceptor grpc.UnaryServerInterceptor, authStreamInterceptor grpc.StreamServerInterceptor, opts ...grpc.ServerOption) []grpc.ServerOption
ServerOptionsWithMetricsAndAuth creates server options with both metrics and auth interceptors
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 StreamClientInterceptor ¶ added in v0.72.0
func StreamClientInterceptor() grpc.StreamClientInterceptor
StreamClientInterceptor returns a client-side stream interceptor for gRPC metrics
func StreamServerInterceptor ¶ added in v0.72.0
func StreamServerInterceptor() grpc.StreamServerInterceptor
StreamServerInterceptor returns a server-side stream interceptor for gRPC metrics
func UnaryClientInterceptor ¶ added in v0.72.0
func UnaryClientInterceptor() grpc.UnaryClientInterceptor
UnaryClientInterceptor returns a client-side unary interceptor for gRPC metrics
func UnaryServerInterceptor ¶ added in v0.72.0
func UnaryServerInterceptor() grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a server-side unary interceptor for gRPC metrics
Types ¶
This section is empty.