package svc import ( "context" "lone-services/services/ws/internal/config" ) type ServiceContext struct { Config config.Config Hub *Hub cancel context.CancelFunc } func NewServiceContext(c config.Config) *ServiceContext { h := NewHub() ctx, cancel := context.WithCancel(context.Background()) go NewSubscriber(h).Run(ctx) return &ServiceContext{ Config: c, Hub: h, cancel: cancel, } } func (s *ServiceContext) Close() { if s.cancel != nil { s.cancel() } }