improves godoc comments for gRPC server and logger components

This commit is contained in:
2025-08-14 09:03:44 -04:00
parent 9cee9037e4
commit e1d58c0094
2 changed files with 7 additions and 6 deletions

View File

@@ -31,8 +31,9 @@ type appGRPCServer struct {
doneChan chan error doneChan chan error
} }
// Returns a shutdown func, a channel indicating done / error, // InitGRPCServer initializes and starts a gRPC server.
// and an up-front error if server fails to start // It returns a shutdown function, a channel to signal completion or error,
// and an error if the server fails to start.
func InitGRPCServer(ctx context.Context, opts *opts.GRPCOpts) ( func InitGRPCServer(ctx context.Context, opts *opts.GRPCOpts) (
func(context.Context) error, <-chan error, error, func(context.Context) error, <-chan error, error,
) { ) {

View File

@@ -8,19 +8,19 @@ import (
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
) )
// A grpc logging middleware compatible logger // GRPCLogger is a grpc logging middleware compatible logger
// implementation using a zerolog logger, either from // implementation using a zerolog logger, either from
// the global logger or a context logger // the global logger or a context logger.
type GRPCLogger struct { type GRPCLogger struct {
logger zerolog.Logger logger zerolog.Logger
} }
// Returns a grpcLogger using the global zerolog Logger // NewGRPCLogger returns a grpcLogger using the global zerolog Logger.
func NewGRPCLogger() *GRPCLogger { func NewGRPCLogger() *GRPCLogger {
return &GRPCLogger{logger: log.Logger} return &GRPCLogger{logger: log.Logger}
} }
// Returns a grpcLogger using the zerolog logger in the provided context // NewGRPCContextLogger returns a grpcLogger using the zerolog logger in the provided context.
func NewGRPCContextLogger(ctx context.Context) *GRPCLogger { func NewGRPCContextLogger(ctx context.Context) *GRPCLogger {
logger := log.Ctx(ctx) logger := log.Ctx(ctx)
return &GRPCLogger{logger: *logger} return &GRPCLogger{logger: *logger}