grpc

package
v0.0.0-...-a53416d Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: MIT Imports: 14 Imported by: 0

README

Server package

TODO

  1. Explain what it is
  2. Generated code - should it be committed? Explain why.

Logging

TODO

Trace id in logs

TODO

Simple implementation, that can be used with opentracing in the future.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogCtxUnaryServerInterceptor

func LogCtxUnaryServerInterceptor() grpc.UnaryServerInterceptor

LogCtxUnaryServerInterceptor returns a new unary server interceptor adding request information to context for logging.

func NewServerError

func NewServerError(err error) error

NewServerError creates error for server response.

func RunServer

RunServer starts grpc server with ServiceServer service. Server is gracefully shut down on context cancellation.

func TraceIDUnaryServerInterceptor

func TraceIDUnaryServerInterceptor() grpc.UnaryServerInterceptor

TraceIDUnaryServerInterceptor returns a new unary server interceptor for generating trace id.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements rpc ServiceServer.

func NewServer

func NewServer(
	bikeService bikerental.BikeService,
	reservationService bikerental.ReservationService,
	log logrus.FieldLogger,
) (*Server, error)

NewServer creates new Server instance.

func (*Server) CancelReservation

func (s *Server) CancelReservation(ctx context.Context, req *bikerentalv1.CancelReservationRequest) (*empty.Empty, error)

CancelReservation cancels reservation for a bike.

func (*Server) CreateBike

CreateBike creates new bike.

func (*Server) CreateReservation

CreateReservation creates new reservation. Returns created object with new id.

func (*Server) DeleteBike

func (s *Server) DeleteBike(ctx context.Context, req *bikerentalv1.DeleteBikeRequest) (*empty.Empty, error)

DeleteBike deletes a bike.

func (*Server) GetBike

GetBike returns a bike.

func (*Server) GetBikeAvailability

GetBikeAvailability checks bike availability in given time ranges.

func (*Server) ListBikes

ListBikes returns list of all bikes.

func (*Server) ListReservations

ListReservations returns list of reservations for a bike.

func (*Server) UpdateBike

func (s *Server) UpdateBike(ctx context.Context, req *bikerentalv1.UpdateBikeRequest) (*empty.Empty, error)

UpdateBike updates a bike.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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