grpc

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package grpc provides common tools, which can be used working with gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnaryClientLoggingInterceptor added in v1.1.7

func UnaryClientLoggingInterceptor(logger *slog.Logger) grpclogging.Logger

UnaryClientLoggingInterceptor adapts slog logger to interceptor logger.

func UnaryServerLoggingInterceptor added in v1.1.7

func UnaryServerLoggingInterceptor(
	logger *slog.Logger,
) func(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryServerLoggingInterceptor intercepts gRPC handler, logs request with provided request ID and calls handler.

Types

type BaseError

type BaseError struct {
	Message string     `json:"message"`
	BaseErr error      `json:"baseErr"`
	Status  codes.Code `json:"-"`
}

BaseError is a base gRPC error, which is used to inform clients, that something went wrong between microservices.

func (BaseError) Error

func (e BaseError) Error() string

func (BaseError) GRPCStatus

func (e BaseError) GRPCStatus() *status.Status

GRPCStatus is a member function, which is used by gRPC when converting an error into a status.

type Config

type Config struct {
	Host string
	Port int
}

Config represents gRPC config to start gRPC server.

Jump to

Keyboard shortcuts

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