grpc

package
v0.0.0-...-fd49e9c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAllScopesPresenceUnaryInterceptor

func CheckAllScopesPresenceUnaryInterceptor(scopes ...string) func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error)

CheckAllScopesPresenceUnaryInterceptor checks if the context contains all specified scopes.

func CheckAnyScopePresenceUnaryInterceptor

func CheckAnyScopePresenceUnaryInterceptor(scopes ...string) func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error)

CheckAnyScopePresenceUnaryInterceptor checks if the context contains at least one of the specified scopes.

func FoundationErrorToStatusUnaryInterceptor

func FoundationErrorToStatusUnaryInterceptor(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

func GetMetadataValue

func GetMetadataValue(ctx context.Context, key string) (s string)

GetMetadataValue retrieves the value of a specified key from the metadata of a gRPC context.

func LoggingUnaryInterceptor

func LoggingUnaryInterceptor(log *logrus.Entry) func(context.Context, interface{}, *grpc.UnaryServerInfo, grpc.UnaryHandler) (interface{}, error)

LoggingUnaryInterceptor returns a gRPC unary interceptor that logs all incoming gRPC calls. It logs the method details, request, response, and any potential errors.

func MetadataUnaryInterceptor

func MetadataUnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

MetadataUnaryInterceptor sets values passed by the gateway from the gRPC metadata into the context.

This is implemented to standardize the retrieval of common values from the context, regardless of whether we are writing gRPC or Event Bus handlers.

func NewTLSConfig

func NewTLSConfig(tlsDir string) (credentials.TransportCredentials, error)

NewTLSConfig initializes a new TransportCredentials instance based on the files located in the provided tlsDir directory. It expects three specific files to be present:

  1. server.crt: This is the server's public certificate file. It's used to authenticate the server to the client.

  2. server.key: This is the server's private key file. This should be kept secret and secure, as it's used in the encryption/decryption process.

  3. ca.crt: This is the certificate authority (CA) certificate. This file is used to validate client certificates for mutual TLS authentication.

Types

This section is empty.

Jump to

Keyboard shortcuts

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