stash/api/resolver_subscription_metad...

30 lines
564 B
Go
Raw Normal View History

2019-02-09 12:30:49 +00:00
package api
import (
"context"
"github.com/stashapp/stash/logger"
"github.com/stashapp/stash/manager"
"time"
)
2019-02-09 12:30:49 +00:00
func (r *subscriptionResolver) MetadataUpdate(ctx context.Context) (<-chan string, error) {
msg := make(chan string, 1)
ticker := time.NewTicker(5 * time.Second)
go func() {
for {
select {
case t := <-ticker.C:
logger.Trace("metadata subscription tick at %s", t)
manager.GetInstance().HandleMetadataUpdateSubscriptionTick(msg)
case <-ctx.Done():
ticker.Stop()
close(msg)
return
}
}
}()
return msg, nil
2019-02-09 12:30:49 +00:00
}