2019-02-09 12:30:49 +00:00
|
|
|
package api
|
|
|
|
|
2019-02-11 22:44:13 +00:00
|
|
|
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) {
|
2019-02-11 22:44:13 +00:00
|
|
|
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
|
|
|
}
|