Documentation
¶
Overview ¶
Package grpc provides a gRPC server implementation.
Index ¶
- type Application
- type Logger
- type RequestData
- type Server
- func (s *Server) CreateEvent(ctx context.Context, event *pb.CreateEventRequest) (*pb.CreateEventResponse, error)
- func (s *Server) DeleteEvent(ctx context.Context, data *pb.DeleteEventRequest) (*pb.DeleteEventResponse, error)
- func (s *Server) GetAllUserEvents(ctx context.Context, data *pb.GetAllUserEventsRequest) (*pb.GetAllUserEventsResponse, error)
- func (s *Server) GetEvent(ctx context.Context, data *pb.GetEventRequest) (*pb.GetEventResponse, error)
- func (s *Server) GetEventsForDay(ctx context.Context, data *pb.GetEventsForDayRequest) (*pb.GetEventsForDayResponse, error)
- func (s *Server) GetEventsForMonth(ctx context.Context, data *pb.GetEventsForMonthRequest) (*pb.GetEventsForMonthResponse, error)
- func (s *Server) GetEventsForPeriod(ctx context.Context, data *pb.GetEventsForPeriodRequest) (*pb.GetEventsForPeriodResponse, error)
- func (s *Server) GetEventsForWeek(ctx context.Context, data *pb.GetEventsForWeekRequest) (*pb.GetEventsForWeekResponse, error)
- func (s *Server) Start(ctx context.Context) error
- func (s *Server) Stop(ctx context.Context) error
- func (s *Server) UpdateEvent(ctx context.Context, data *pb.UpdateEventRequest) (*pb.UpdateEventResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application interface {
// CreateEvent is trying to build an Event object and save it in the storage.
CreateEvent(ctx context.Context, input *dto.CreateEventInput) (*types.Event, error)
// UpdateEvent is trying to get the existing Event from the storage, update it and save back.
UpdateEvent(ctx context.Context, input *dto.UpdateEventInput) (*types.Event, error)
// DeleteEvent is trying to delete the Event with the given ID from the storage.
DeleteEvent(ctx context.Context, id string) error
// GetEvent is trying to get the Event with the given ID from the storage.
GetEvent(ctx context.Context, id string) (*types.Event, error)
// GetAllUserEvents is trying to get all events for a given user ID from the storage.
GetAllUserEvents(ctx context.Context, userID string) ([]*types.Event, error)
// ListEvents is trying to get all events for a given user ID from the storage.
ListEvents(ctx context.Context, input *dto.DateFilterInput) ([]*types.Event, error)
// GetEventsForPeriod is trying to get all events for a given period from the storage.
GetEventsForPeriod(ctx context.Context, input *dto.DateRangeInput) ([]*types.Event, error)
}
Application represents an interface of application visible to the server.
type Logger ¶
type Logger interface {
// Info logs a message with level Info on the standard logger.
Info(ctx context.Context, msg string, args ...any)
// Debug logs a message with level Debug on the standard logger.
Debug(ctx context.Context, msg string, args ...any)
// Warn logs a message with level Warn on the standard logger.
Warn(ctx context.Context, msg string, args ...any)
// Error logs a message with level Error on the standard logger.
Error(ctx context.Context, msg string, args ...any)
}
Logger represents an interface of logger visible to the app.
type RequestData ¶
RequestData represents a data structure for storing request data.
type Server ¶
type Server struct {
pb.UnimplementedEventsServiceServer
// contains filtered or unexported fields
}
Server represents a gRPC server.
func NewServer ¶
NewServer creates a new gRPC server. The function performs validation of the input parameters. If no error occurs, it returns *Server, nil and nil, error otherwise.
func (*Server) CreateEvent ¶
func (s *Server) CreateEvent(ctx context.Context, event *pb.CreateEventRequest) (*pb.CreateEventResponse, error)
CreateEvent validates the request data and tries to create a new event in the storage.
func (*Server) DeleteEvent ¶
func (s *Server) DeleteEvent(ctx context.Context, data *pb.DeleteEventRequest) (*pb.DeleteEventResponse, error)
DeleteEvent tries to delete the Event with the given ID from the storage.
func (*Server) GetAllUserEvents ¶
func (s *Server) GetAllUserEvents(ctx context.Context, data *pb.GetAllUserEventsRequest) ( *pb.GetAllUserEventsResponse, error, )
GetAllUserEvents is trying to get all events for a given user ID from the storage.
func (*Server) GetEvent ¶
func (s *Server) GetEvent(ctx context.Context, data *pb.GetEventRequest) (*pb.GetEventResponse, error)
GetEvent tries to get the Event with the given ID from the storage.
func (*Server) GetEventsForDay ¶
func (s *Server) GetEventsForDay( ctx context.Context, data *pb.GetEventsForDayRequest, ) (*pb.GetEventsForDayResponse, error)
GetEventsForDay is trying to get all events for a given day from the storage.
func (*Server) GetEventsForMonth ¶
func (s *Server) GetEventsForMonth( ctx context.Context, data *pb.GetEventsForMonthRequest, ) (*pb.GetEventsForMonthResponse, error)
GetEventsForMonth is trying to get all events for a given month from the storage.
func (*Server) GetEventsForPeriod ¶
func (s *Server) GetEventsForPeriod( ctx context.Context, data *pb.GetEventsForPeriodRequest, ) (*pb.GetEventsForPeriodResponse, error)
GetEventsForPeriod is trying to get all events for a given period from the storage.
func (*Server) GetEventsForWeek ¶
func (s *Server) GetEventsForWeek( ctx context.Context, data *pb.GetEventsForWeekRequest, ) (*pb.GetEventsForWeekResponse, error)
GetEventsForWeek is trying to get all events for a given week from the storage.
func (*Server) Start ¶
Start starts the gRPC server. Start blocks the calling goroutine until the error returns.
func (*Server) UpdateEvent ¶
func (s *Server) UpdateEvent(ctx context.Context, data *pb.UpdateEventRequest) (*pb.UpdateEventResponse, error)
UpdateEvent validates the request data and tries to update an existing event in the storage.