Change logging and implement gRPC

This commit is contained in:
2025-10-18 23:12:25 -07:00
parent 769fd5e2aa
commit 8229944149
14 changed files with 545 additions and 2100 deletions
+351
View File
@@ -0,0 +1,351 @@
package grpc
import (
"context"
"fmt"
pb "github.com/igodwin/notifier/api/grpc/pb"
"github.com/igodwin/notifier/internal/domain"
"google.golang.org/protobuf/types/known/timestamppb"
)
// NotifierHandler implements the gRPC NotifierService
type NotifierHandler struct {
pb.UnimplementedNotifierServiceServer
service domain.NotificationService
}
// NewNotifierHandler creates a new gRPC handler
func NewNotifierHandler(svc domain.NotificationService) *NotifierHandler {
return &NotifierHandler{
service: svc,
}
}
// HealthCheck verifies the service is operational
func (h *NotifierHandler) HealthCheck(ctx context.Context, req *pb.HealthCheckRequest) (*pb.HealthCheckResponse, error) {
// TODO: Implement proper health check logic
return &pb.HealthCheckResponse{
Healthy: true,
Status: "ok",
Components: map[string]string{
"service": "running",
},
}, nil
}
// SendNotification sends a single notification
func (h *NotifierHandler) SendNotification(ctx context.Context, req *pb.SendNotificationRequest) (*pb.SendNotificationResponse, error) {
// Convert proto notification type to domain type
notifType := convertProtoTypeToDomain(req.Type)
// Build notification
notification := &domain.Notification{
Type: notifType,
Account: req.Account,
Priority: domain.Priority(req.Priority),
Subject: req.Subject,
Body: req.Body,
Recipients: req.Recipients,
Metadata: convertStringMapToInterface(req.Metadata),
MaxRetries: int(req.MaxRetries),
}
if req.ScheduledFor != nil {
scheduledTime := req.ScheduledFor.AsTime()
notification.ScheduledFor = &scheduledTime
}
// Send notification
result, err := h.service.Send(ctx, notification)
if err != nil {
return &pb.SendNotificationResponse{
Result: &pb.NotificationResult{
Success: false,
Error: err.Error(),
},
}, nil
}
// Convert result to proto
return &pb.SendNotificationResponse{
Result: &pb.NotificationResult{
NotificationId: result.NotificationID,
Success: result.Success,
Message: result.Message,
SentAt: timestamppb.New(result.SentAt),
},
}, nil
}
// SendBatchNotifications sends multiple notifications
func (h *NotifierHandler) SendBatchNotifications(ctx context.Context, req *pb.SendBatchNotificationsRequest) (*pb.SendBatchNotificationsResponse, error) {
var results []*pb.NotificationResult
for _, notifReq := range req.Notifications {
resp, err := h.SendNotification(ctx, notifReq)
if err != nil {
results = append(results, &pb.NotificationResult{
Success: false,
Error: err.Error(),
})
} else {
results = append(results, resp.Result)
}
}
return &pb.SendBatchNotificationsResponse{
Results: results,
}, nil
}
// GetNotification retrieves a notification by ID
func (h *NotifierHandler) GetNotification(ctx context.Context, req *pb.GetNotificationRequest) (*pb.GetNotificationResponse, error) {
notification, err := h.service.GetNotification(ctx, req.Id)
if err != nil {
return nil, err
}
return &pb.GetNotificationResponse{
Notification: convertDomainToProtoNotification(notification),
}, nil
}
// ListNotifications retrieves notifications matching a filter
func (h *NotifierHandler) ListNotifications(ctx context.Context, req *pb.ListNotificationsRequest) (*pb.ListNotificationsResponse, error) {
// Convert proto filter to domain filter
filter := convertProtoFilterToDomain(req.Filter)
notifications, err := h.service.ListNotifications(ctx, filter)
if err != nil {
return nil, err
}
protoNotifications := make([]*pb.Notification, len(notifications))
for i, notif := range notifications {
protoNotifications[i] = convertDomainToProtoNotification(notif)
}
return &pb.ListNotificationsResponse{
Notifications: protoNotifications,
Total: int64(len(notifications)),
}, nil
}
// CancelNotification cancels a pending notification
func (h *NotifierHandler) CancelNotification(ctx context.Context, req *pb.CancelNotificationRequest) (*pb.CancelNotificationResponse, error) {
err := h.service.CancelNotification(ctx, req.Id)
if err != nil {
return &pb.CancelNotificationResponse{
Success: false,
Message: err.Error(),
}, nil
}
return &pb.CancelNotificationResponse{
Success: true,
Message: "notification cancelled successfully",
}, nil
}
// RetryNotification retries a failed notification
func (h *NotifierHandler) RetryNotification(ctx context.Context, req *pb.RetryNotificationRequest) (*pb.RetryNotificationResponse, error) {
result, err := h.service.RetryNotification(ctx, req.Id)
if err != nil {
return &pb.RetryNotificationResponse{
Result: &pb.NotificationResult{
Success: false,
Error: err.Error(),
},
}, nil
}
return &pb.RetryNotificationResponse{
Result: &pb.NotificationResult{
NotificationId: result.NotificationID,
Success: result.Success,
Message: result.Message,
SentAt: timestamppb.New(result.SentAt),
},
}, nil
}
// GetStats returns notification statistics
func (h *NotifierHandler) GetStats(ctx context.Context, req *pb.GetStatsRequest) (*pb.GetStatsResponse, error) {
stats, err := h.service.GetStats(ctx)
if err != nil {
return nil, err
}
return &pb.GetStatsResponse{
TotalSent: stats.TotalSent,
TotalFailed: stats.TotalFailed,
TotalPending: stats.TotalPending,
TotalQueued: stats.TotalQueued,
ByType: stats.ByType,
ByStatus: stats.ByStatus,
}, nil
}
// Helper functions to convert between proto and domain types
// convertStringMapToInterface converts proto's map[string]string to domain's map[string]interface{}
func convertStringMapToInterface(m map[string]string) map[string]interface{} {
if m == nil {
return nil
}
result := make(map[string]interface{}, len(m))
for k, v := range m {
result[k] = v
}
return result
}
// convertInterfaceMapToString converts domain's map[string]interface{} to proto's map[string]string
func convertInterfaceMapToString(m map[string]interface{}) map[string]string {
if m == nil {
return nil
}
result := make(map[string]string, len(m))
for k, v := range m {
if v != nil {
result[k] = fmt.Sprint(v)
}
}
return result
}
func convertProtoTypeToDomain(protoType pb.NotificationType) domain.NotificationType {
switch protoType {
case pb.NotificationType_NOTIFICATION_TYPE_EMAIL:
return domain.TypeEmail
case pb.NotificationType_NOTIFICATION_TYPE_SLACK:
return domain.TypeSlack
case pb.NotificationType_NOTIFICATION_TYPE_NTFY:
return domain.TypeNtfy
case pb.NotificationType_NOTIFICATION_TYPE_STDOUT:
return domain.TypeStdout
default:
return domain.TypeStdout
}
}
func convertDomainToProtoType(domainType domain.NotificationType) pb.NotificationType {
switch domainType {
case domain.TypeEmail:
return pb.NotificationType_NOTIFICATION_TYPE_EMAIL
case domain.TypeSlack:
return pb.NotificationType_NOTIFICATION_TYPE_SLACK
case domain.TypeNtfy:
return pb.NotificationType_NOTIFICATION_TYPE_NTFY
case domain.TypeStdout:
return pb.NotificationType_NOTIFICATION_TYPE_STDOUT
default:
return pb.NotificationType_NOTIFICATION_TYPE_UNSPECIFIED
}
}
func convertDomainToProtoStatus(status domain.NotificationStatus) pb.NotificationStatus {
switch status {
case domain.StatusPending:
return pb.NotificationStatus_NOTIFICATION_STATUS_PENDING
case domain.StatusQueued:
return pb.NotificationStatus_NOTIFICATION_STATUS_QUEUED
case domain.StatusProcessing:
return pb.NotificationStatus_NOTIFICATION_STATUS_PROCESSING
case domain.StatusSent:
return pb.NotificationStatus_NOTIFICATION_STATUS_SENT
case domain.StatusFailed:
return pb.NotificationStatus_NOTIFICATION_STATUS_FAILED
case domain.StatusRetrying:
return pb.NotificationStatus_NOTIFICATION_STATUS_RETRYING
default:
return pb.NotificationStatus_NOTIFICATION_STATUS_UNSPECIFIED
}
}
func convertDomainToProtoNotification(notif *domain.Notification) *pb.Notification {
protoNotif := &pb.Notification{
Id: notif.ID,
Type: convertDomainToProtoType(notif.Type),
Account: notif.Account,
Priority: pb.Priority(notif.Priority),
Status: convertDomainToProtoStatus(notif.Status),
Subject: notif.Subject,
Body: notif.Body,
Recipients: notif.Recipients,
Metadata: convertInterfaceMapToString(notif.Metadata),
CreatedAt: timestamppb.New(notif.CreatedAt),
RetryCount: int32(notif.RetryCount),
MaxRetries: int32(notif.MaxRetries),
LastError: notif.LastError,
}
// Handle optional timestamp fields
if notif.ScheduledFor != nil {
protoNotif.ScheduledFor = timestamppb.New(*notif.ScheduledFor)
}
if notif.SentAt != nil {
protoNotif.SentAt = timestamppb.New(*notif.SentAt)
}
return protoNotif
}
func convertProtoFilterToDomain(filter *pb.NotificationFilter) *domain.NotificationFilter {
if filter == nil {
return &domain.NotificationFilter{}
}
// Convert proto types to domain types
var types []domain.NotificationType
for _, protoType := range filter.Types {
types = append(types, convertProtoTypeToDomain(protoType))
}
// Convert proto statuses to domain statuses
var statuses []domain.NotificationStatus
for _, protoStatus := range filter.Statuses {
statuses = append(statuses, convertProtoStatusToDomain(protoStatus))
}
domainFilter := &domain.NotificationFilter{
IDs: filter.Ids,
Types: types,
Statuses: statuses,
Recipients: filter.Recipients,
Limit: int(filter.Limit),
Offset: int(filter.Offset),
}
if filter.CreatedAfter != nil {
createdAfter := filter.CreatedAfter.AsTime()
domainFilter.CreatedAfter = &createdAfter
}
if filter.CreatedBefore != nil {
createdBefore := filter.CreatedBefore.AsTime()
domainFilter.CreatedBefore = &createdBefore
}
return domainFilter
}
func convertProtoStatusToDomain(protoStatus pb.NotificationStatus) domain.NotificationStatus {
switch protoStatus {
case pb.NotificationStatus_NOTIFICATION_STATUS_PENDING:
return domain.StatusPending
case pb.NotificationStatus_NOTIFICATION_STATUS_QUEUED:
return domain.StatusQueued
case pb.NotificationStatus_NOTIFICATION_STATUS_PROCESSING:
return domain.StatusProcessing
case pb.NotificationStatus_NOTIFICATION_STATUS_SENT:
return domain.StatusSent
case pb.NotificationStatus_NOTIFICATION_STATUS_FAILED:
return domain.StatusFailed
case pb.NotificationStatus_NOTIFICATION_STATUS_RETRYING:
return domain.StatusRetrying
default:
return domain.StatusPending
}
}
File diff suppressed because it is too large Load Diff
-407
View File
@@ -1,407 +0,0 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.5.1
// - protoc v6.33.0
// source: api/grpc/notifier.proto
package pb
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.64.0 or later.
const _ = grpc.SupportPackageIsVersion9
const (
NotifierService_SendNotification_FullMethodName = "/notifier.v1.NotifierService/SendNotification"
NotifierService_SendBatchNotifications_FullMethodName = "/notifier.v1.NotifierService/SendBatchNotifications"
NotifierService_GetNotification_FullMethodName = "/notifier.v1.NotifierService/GetNotification"
NotifierService_ListNotifications_FullMethodName = "/notifier.v1.NotifierService/ListNotifications"
NotifierService_CancelNotification_FullMethodName = "/notifier.v1.NotifierService/CancelNotification"
NotifierService_RetryNotification_FullMethodName = "/notifier.v1.NotifierService/RetryNotification"
NotifierService_GetStats_FullMethodName = "/notifier.v1.NotifierService/GetStats"
NotifierService_HealthCheck_FullMethodName = "/notifier.v1.NotifierService/HealthCheck"
)
// NotifierServiceClient is the client API for NotifierService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
//
// NotifierService handles notification operations
type NotifierServiceClient interface {
// SendNotification sends a single notification
SendNotification(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error)
// SendBatchNotifications sends multiple notifications
SendBatchNotifications(ctx context.Context, in *SendBatchNotificationsRequest, opts ...grpc.CallOption) (*SendBatchNotificationsResponse, error)
// GetNotification retrieves a notification by ID
GetNotification(ctx context.Context, in *GetNotificationRequest, opts ...grpc.CallOption) (*GetNotificationResponse, error)
// ListNotifications retrieves notifications matching a filter
ListNotifications(ctx context.Context, in *ListNotificationsRequest, opts ...grpc.CallOption) (*ListNotificationsResponse, error)
// CancelNotification cancels a pending notification
CancelNotification(ctx context.Context, in *CancelNotificationRequest, opts ...grpc.CallOption) (*CancelNotificationResponse, error)
// RetryNotification retries a failed notification
RetryNotification(ctx context.Context, in *RetryNotificationRequest, opts ...grpc.CallOption) (*RetryNotificationResponse, error)
// GetStats returns notification statistics
GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error)
// HealthCheck verifies the service is operational
HealthCheck(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error)
}
type notifierServiceClient struct {
cc grpc.ClientConnInterface
}
func NewNotifierServiceClient(cc grpc.ClientConnInterface) NotifierServiceClient {
return &notifierServiceClient{cc}
}
func (c *notifierServiceClient) SendNotification(ctx context.Context, in *SendNotificationRequest, opts ...grpc.CallOption) (*SendNotificationResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SendNotificationResponse)
err := c.cc.Invoke(ctx, NotifierService_SendNotification_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) SendBatchNotifications(ctx context.Context, in *SendBatchNotificationsRequest, opts ...grpc.CallOption) (*SendBatchNotificationsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(SendBatchNotificationsResponse)
err := c.cc.Invoke(ctx, NotifierService_SendBatchNotifications_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) GetNotification(ctx context.Context, in *GetNotificationRequest, opts ...grpc.CallOption) (*GetNotificationResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetNotificationResponse)
err := c.cc.Invoke(ctx, NotifierService_GetNotification_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) ListNotifications(ctx context.Context, in *ListNotificationsRequest, opts ...grpc.CallOption) (*ListNotificationsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListNotificationsResponse)
err := c.cc.Invoke(ctx, NotifierService_ListNotifications_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) CancelNotification(ctx context.Context, in *CancelNotificationRequest, opts ...grpc.CallOption) (*CancelNotificationResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(CancelNotificationResponse)
err := c.cc.Invoke(ctx, NotifierService_CancelNotification_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) RetryNotification(ctx context.Context, in *RetryNotificationRequest, opts ...grpc.CallOption) (*RetryNotificationResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(RetryNotificationResponse)
err := c.cc.Invoke(ctx, NotifierService_RetryNotification_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) GetStats(ctx context.Context, in *GetStatsRequest, opts ...grpc.CallOption) (*GetStatsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(GetStatsResponse)
err := c.cc.Invoke(ctx, NotifierService_GetStats_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *notifierServiceClient) HealthCheck(ctx context.Context, in *HealthCheckRequest, opts ...grpc.CallOption) (*HealthCheckResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(HealthCheckResponse)
err := c.cc.Invoke(ctx, NotifierService_HealthCheck_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// NotifierServiceServer is the server API for NotifierService service.
// All implementations must embed UnimplementedNotifierServiceServer
// for forward compatibility.
//
// NotifierService handles notification operations
type NotifierServiceServer interface {
// SendNotification sends a single notification
SendNotification(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error)
// SendBatchNotifications sends multiple notifications
SendBatchNotifications(context.Context, *SendBatchNotificationsRequest) (*SendBatchNotificationsResponse, error)
// GetNotification retrieves a notification by ID
GetNotification(context.Context, *GetNotificationRequest) (*GetNotificationResponse, error)
// ListNotifications retrieves notifications matching a filter
ListNotifications(context.Context, *ListNotificationsRequest) (*ListNotificationsResponse, error)
// CancelNotification cancels a pending notification
CancelNotification(context.Context, *CancelNotificationRequest) (*CancelNotificationResponse, error)
// RetryNotification retries a failed notification
RetryNotification(context.Context, *RetryNotificationRequest) (*RetryNotificationResponse, error)
// GetStats returns notification statistics
GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error)
// HealthCheck verifies the service is operational
HealthCheck(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error)
mustEmbedUnimplementedNotifierServiceServer()
}
// UnimplementedNotifierServiceServer must be embedded to have
// forward compatible implementations.
//
// NOTE: this should be embedded by value instead of pointer to avoid a nil
// pointer dereference when methods are called.
type UnimplementedNotifierServiceServer struct{}
func (UnimplementedNotifierServiceServer) SendNotification(context.Context, *SendNotificationRequest) (*SendNotificationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendNotification not implemented")
}
func (UnimplementedNotifierServiceServer) SendBatchNotifications(context.Context, *SendBatchNotificationsRequest) (*SendBatchNotificationsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method SendBatchNotifications not implemented")
}
func (UnimplementedNotifierServiceServer) GetNotification(context.Context, *GetNotificationRequest) (*GetNotificationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetNotification not implemented")
}
func (UnimplementedNotifierServiceServer) ListNotifications(context.Context, *ListNotificationsRequest) (*ListNotificationsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListNotifications not implemented")
}
func (UnimplementedNotifierServiceServer) CancelNotification(context.Context, *CancelNotificationRequest) (*CancelNotificationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CancelNotification not implemented")
}
func (UnimplementedNotifierServiceServer) RetryNotification(context.Context, *RetryNotificationRequest) (*RetryNotificationResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method RetryNotification not implemented")
}
func (UnimplementedNotifierServiceServer) GetStats(context.Context, *GetStatsRequest) (*GetStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetStats not implemented")
}
func (UnimplementedNotifierServiceServer) HealthCheck(context.Context, *HealthCheckRequest) (*HealthCheckResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method HealthCheck not implemented")
}
func (UnimplementedNotifierServiceServer) mustEmbedUnimplementedNotifierServiceServer() {}
func (UnimplementedNotifierServiceServer) testEmbeddedByValue() {}
// UnsafeNotifierServiceServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to NotifierServiceServer will
// result in compilation errors.
type UnsafeNotifierServiceServer interface {
mustEmbedUnimplementedNotifierServiceServer()
}
func RegisterNotifierServiceServer(s grpc.ServiceRegistrar, srv NotifierServiceServer) {
// If the following call pancis, it indicates UnimplementedNotifierServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
t.testEmbeddedByValue()
}
s.RegisterService(&NotifierService_ServiceDesc, srv)
}
func _NotifierService_SendNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SendNotificationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).SendNotification(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_SendNotification_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).SendNotification(ctx, req.(*SendNotificationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_SendBatchNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(SendBatchNotificationsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).SendBatchNotifications(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_SendBatchNotifications_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).SendBatchNotifications(ctx, req.(*SendBatchNotificationsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_GetNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetNotificationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).GetNotification(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_GetNotification_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).GetNotification(ctx, req.(*GetNotificationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_ListNotifications_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListNotificationsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).ListNotifications(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_ListNotifications_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).ListNotifications(ctx, req.(*ListNotificationsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_CancelNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CancelNotificationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).CancelNotification(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_CancelNotification_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).CancelNotification(ctx, req.(*CancelNotificationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_RetryNotification_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RetryNotificationRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).RetryNotification(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_RetryNotification_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).RetryNotification(ctx, req.(*RetryNotificationRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_GetStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).GetStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_GetStats_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).GetStats(ctx, req.(*GetStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _NotifierService_HealthCheck_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(HealthCheckRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NotifierServiceServer).HealthCheck(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: NotifierService_HealthCheck_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NotifierServiceServer).HealthCheck(ctx, req.(*HealthCheckRequest))
}
return interceptor(ctx, in, info, handler)
}
// NotifierService_ServiceDesc is the grpc.ServiceDesc for NotifierService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var NotifierService_ServiceDesc = grpc.ServiceDesc{
ServiceName: "notifier.v1.NotifierService",
HandlerType: (*NotifierServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "SendNotification",
Handler: _NotifierService_SendNotification_Handler,
},
{
MethodName: "SendBatchNotifications",
Handler: _NotifierService_SendBatchNotifications_Handler,
},
{
MethodName: "GetNotification",
Handler: _NotifierService_GetNotification_Handler,
},
{
MethodName: "ListNotifications",
Handler: _NotifierService_ListNotifications_Handler,
},
{
MethodName: "CancelNotification",
Handler: _NotifierService_CancelNotification_Handler,
},
{
MethodName: "RetryNotification",
Handler: _NotifierService_RetryNotification_Handler,
},
{
MethodName: "GetStats",
Handler: _NotifierService_GetStats_Handler,
},
{
MethodName: "HealthCheck",
Handler: _NotifierService_HealthCheck_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/grpc/notifier.proto",
}