grpc

package
v0.0.0-...-23a1a97 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldLength = 2
)

Variables

View Source
var Module = fx.Options(
	fx.Provide(
		func() (*grpc.Server, error) {
			return NewServer()
		},
	),
	fx.Invoke(
		func(lc fx.Lifecycle, grpcServer *grpc.Server) error {
			lc.Append(
				fx.Hook{
					OnStart: func(context.Context) error {
						listener, err := net.Listen("tcp", fmt.Sprintf(":%s", environment.GetGRPCPort()))
						if err != nil {
							return fmt.Errorf("failed to listen: %w", err)
						}
						server := &HealthCheck{}
						healthpb.RegisterHealthServer(grpcServer, server)
						go func() {
							if err := grpcServer.Serve(listener); err != nil {
								panic(err)
							}
						}()
						return nil
					},
					OnStop: func(context.Context) error {
						grpcServer.GracefulStop()
						return nil
					},
				},
			)
			return nil
		},
	),
)

Functions

func InterceptorLogger

func InterceptorLogger(logger *zap.Logger) logging.Logger

func NewServer

func NewServer() (*grpc.Server, error)

Types

type HealthCheck

type HealthCheck struct {
	healthgrpc.UnimplementedHealthServer
}

func (*HealthCheck) Watch

Jump to

Keyboard shortcuts

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