- Add new `app` package to manage application initialization and lifecycle - Refactor `main.go` to use new application management approach - Implement graceful shutdown with context timeout and signal handling - Add dependency injection container initialization - Enhance logging with configurable log levels and structured logging - Update configuration loading and server initialization process - Modify Jitsi configuration in `.env` for custom deployment - Improve error handling and logging throughout application startup - Centralize application startup and shutdown logic in single package Introduces a more robust and flexible application management system with improved initialization, logging, and shutdown capabilities.
55 lines
1.5 KiB
Go
55 lines
1.5 KiB
Go
package services
|
|
|
|
import (
|
|
"time"
|
|
|
|
"attune-heart-therapy/internal/jobs"
|
|
"attune-heart-therapy/internal/repositories"
|
|
)
|
|
|
|
// jobManagerService implements the JobManagerService interface
|
|
type jobManagerService struct {
|
|
manager *jobs.Manager
|
|
}
|
|
|
|
// NewJobManagerService creates a new job manager service
|
|
func NewJobManagerService(
|
|
notificationService NotificationService,
|
|
bookingRepo repositories.BookingRepository,
|
|
userRepo repositories.UserRepository,
|
|
) JobManagerService {
|
|
// Use default config from jobs package
|
|
manager := jobs.NewManager(notificationService, bookingRepo, userRepo, nil)
|
|
|
|
return &jobManagerService{
|
|
manager: manager,
|
|
}
|
|
}
|
|
|
|
// Start starts the job manager
|
|
func (s *jobManagerService) Start() error {
|
|
return s.manager.Start()
|
|
}
|
|
|
|
// Stop stops the job manager
|
|
func (s *jobManagerService) Stop() error {
|
|
return s.manager.Stop()
|
|
}
|
|
|
|
// IsRunning returns whether the job manager is running
|
|
func (s *jobManagerService) IsRunning() bool {
|
|
return s.manager.IsRunning()
|
|
}
|
|
|
|
// ScheduleRemindersForBooking schedules reminders for a booking
|
|
func (s *jobManagerService) ScheduleRemindersForBooking(bookingID uint, userID uint, meetingTime time.Time) error {
|
|
reminderScheduler := s.manager.GetReminderScheduler()
|
|
return reminderScheduler.ScheduleRemindersForBooking(bookingID, userID, meetingTime)
|
|
}
|
|
|
|
// CancelRemindersForBooking cancels reminders for a booking
|
|
func (s *jobManagerService) CancelRemindersForBooking(bookingID uint) error {
|
|
reminderScheduler := s.manager.GetReminderScheduler()
|
|
return reminderScheduler.CancelRemindersForBooking(bookingID)
|
|
}
|