mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
28 lines
562 B
Go
28 lines
562 B
Go
package sessions
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/sablierapp/sablier/app/providers"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// watchGroups watches indefinitely for new groups
|
|
func watchGroups(ctx context.Context, provider providers.Provider, frequency time.Duration, send chan<- map[string][]string) {
|
|
ticker := time.NewTicker(frequency)
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return
|
|
case <-ticker.C:
|
|
groups, err := provider.GetGroups(ctx)
|
|
if err != nil {
|
|
log.Warn("could not get groups", err)
|
|
} else {
|
|
send <- groups
|
|
}
|
|
}
|
|
}
|
|
}
|