feat: use sync groups for better cancellation

This commit is contained in:
Stavros
2026-05-08 18:08:27 +03:00
parent b73a9db061
commit 71ddfbbdba
7 changed files with 61 additions and 34 deletions
+5 -2
View File
@@ -17,6 +17,7 @@ type LdapService struct {
log *logger.Logger
config model.Config
context context.Context
wg *sync.WaitGroup
conn *ldapgo.Conn
mutex sync.RWMutex
@@ -28,11 +29,13 @@ func NewLdapService(
log *logger.Logger,
config model.Config,
context context.Context,
wg *sync.WaitGroup,
) *LdapService {
return &LdapService{
log: log,
config: config,
context: context,
wg: wg,
}
}
@@ -88,7 +91,7 @@ func (ldap *LdapService) Init() error {
return fmt.Errorf("failed to connect to LDAP server: %w", err)
}
go func() {
ldap.wg.Go(func() {
ldap.log.App.Debug().Msg("Starting LDAP connection heartbeat routine")
ticker := time.NewTicker(5 * time.Minute)
@@ -111,7 +114,7 @@ func (ldap *LdapService) Init() error {
return
}
}
}()
})
return nil
}