init.go 606 B

123456789101112131415161718192021222324252627
  1. package event
  2. import (
  3. "context"
  4. "github.com/uozi-tech/cosy/logger"
  5. )
  6. // InitEventSystem initializes the event system
  7. func InitEventSystem(ctx context.Context) {
  8. logger.Info("Initializing event system...")
  9. // Initialize the event bus by getting the singleton instance
  10. GetEventBus()
  11. logger.Info("Event system initialized successfully")
  12. defer ShutdownEventSystem()
  13. <-ctx.Done()
  14. }
  15. // ShutdownEventSystem gracefully shuts down the event system
  16. func ShutdownEventSystem() {
  17. logger.Info("Shutting down event system...")
  18. GetEventBus().Shutdown()
  19. logger.Info("Event system shutdown completed")
  20. }