Integrate Notification Service into Tender Management System
- Added a new notification service to handle various notification types (email, SMS, push, OTP). - Implemented configuration for the notification service, allowing customization via environment variables. - Updated user and customer services to utilize the notification service for sending welcome emails and status updates. - Introduced a builder pattern for constructing notification requests, enhancing usability and flexibility. - Enhanced error handling and logging for notification operations, ensuring robust service integration. - Updated documentation to include usage examples and configuration details for the new notification SDK.
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"tm/pkg/config"
|
||||
"tm/pkg/logger"
|
||||
"tm/pkg/mongo"
|
||||
"tm/pkg/notification"
|
||||
"tm/pkg/redis"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
@@ -175,3 +176,34 @@ func InitAuthorizationService(conf JWTConfig, redisClient redis.Client, log logg
|
||||
|
||||
return authService
|
||||
}
|
||||
|
||||
// Init Notification Service
|
||||
func InitNotificationService(conf config.NotificationConfig, log logger.Logger) notification.SDK {
|
||||
notificationConfig := ¬ification.Config{
|
||||
BaseURL: conf.BaseURL,
|
||||
Timeout: conf.Timeout,
|
||||
RetryAttempts: conf.RetryAttempts,
|
||||
RetryDelay: conf.RetryDelay,
|
||||
EnableLogging: conf.EnableLogging,
|
||||
UserAgent: conf.UserAgent,
|
||||
}
|
||||
|
||||
notificationSDK, err := notification.New(notificationConfig, log)
|
||||
if err != nil {
|
||||
log.Error("Failed to initialize Notification SDK", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
})
|
||||
fmt.Printf("Failed to initialize Notification SDK: %v\n", err.Error())
|
||||
}
|
||||
|
||||
log.Info("Notification SDK initialized successfully", map[string]interface{}{
|
||||
"base_url": conf.BaseURL,
|
||||
"timeout": conf.Timeout,
|
||||
"retry_attempts": conf.RetryAttempts,
|
||||
"retry_delay": conf.RetryDelay,
|
||||
"enable_logging": conf.EnableLogging,
|
||||
"user_agent": conf.UserAgent,
|
||||
})
|
||||
|
||||
return *notificationSDK
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ type Config struct {
|
||||
Logging config.LoggingConfig
|
||||
RateLimit config.RateLimitConfig
|
||||
Assets config.AssetsConfig
|
||||
Notification config.NotificationConfig
|
||||
UserAuth AuthConfig
|
||||
CustomerAuth AuthConfig
|
||||
}
|
||||
|
||||
+5
-2
@@ -122,6 +122,9 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Initialize notification service
|
||||
notificationSDK := bootstrap.InitNotificationService(conf.Notification, logger)
|
||||
|
||||
// Initialize authorization service
|
||||
userAuthService := bootstrap.InitAuthorizationService(conf.UserAuth.JWT, redisClient, logger)
|
||||
customerAuthService := bootstrap.InitAuthorizationService(conf.CustomerAuth.JWT, redisClient, logger)
|
||||
@@ -143,10 +146,10 @@ func main() {
|
||||
userValidator := user.NewValidationService()
|
||||
|
||||
// Initialize services with repositories
|
||||
userService := user.NewUserService(userRepository, logger, userAuthService, userValidator)
|
||||
userService := user.NewUserService(userRepository, logger, userAuthService, userValidator, notificationSDK)
|
||||
categoryService := company_category.NewCategoryService(categoryRepository, logger)
|
||||
companyService := company.NewCompanyService(companyRepository, categoryService, logger)
|
||||
customerService := customer.New(customerRepository, logger, customerAuthService, companyService, redisClient)
|
||||
customerService := customer.New(customerRepository, logger, customerAuthService, companyService, redisClient, notificationSDK)
|
||||
tenderService := tender.NewTenderService(tenderRepository, companyService, logger)
|
||||
feedbackService := feedback.NewFeedbackService(feedbackRepo, tenderService, logger)
|
||||
tenderApprovalService := tender_approval.NewTenderApprovalService(tenderApprovalRepository, tenderService, logger)
|
||||
|
||||
Reference in New Issue
Block a user