Files
sablier/app/sessions/groups_watcher.go
2024-10-20 23:54:53 -04:00

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
}
}
}
}