grpc

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FightersController

type FightersController interface {
	SearchFightersCount(ctx context.Context, req *model.FightersRequest) (int32, error)
	SearchFighters(ctx context.Context, req *model.FightersRequest) ([]*model.Fighter, error)
	HealthCheck() *model.HealthStatus
}

type Handler

type Handler struct {
	gen.UnimplementedFightersServiceServer
	// contains filtered or unexported fields
}

Handler defines a Fighters gRPC handler.

func New

func New(ctrl FightersController) *Handler

New creates a new Fighters gRPC handler.

func (*Handler) HealthCheck

func (h *Handler) HealthCheck(ctx context.Context, req *emptypb.Empty) (*gen.HealthResponse, error)

HealthCheck handles the gRPC request for checking the health status of the application. It delegates the call to the controller and converts the result into a protobuf response.

func (*Handler) SearchFighters

func (h *Handler) SearchFighters(ctx context.Context, req *gen.FightersRequest) (*gen.FightersResponse, error)

SearchFighters retrieves fighters based on the provided request. It converts the request to the internal model, calls the controller's method, and returns the response. If no fighters are found, it returns a NotFound error; otherwise, it returns the list of fighters.

func (*Handler) SearchFightersCount

func (h *Handler) SearchFightersCount(ctx context.Context, req *gen.FightersRequest) (*gen.FightersCountResponse, error)

SearchFightersCount retrieves the count of fighters based on the provided request. It converts the request to the internal model, calls the controller's method, and returns the count.

Jump to

Keyboard shortcuts

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