32 lines
944 B
Go
32 lines
944 B
Go
package workers
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"git.ipao.vip/rogee/creator-hub/internal/account"
|
|
"git.ipao.vip/rogee/creator-hub/internal/controlplane/api"
|
|
creatorDomain "git.ipao.vip/rogee/creator-hub/internal/creator"
|
|
"git.ipao.vip/rogee/creator-hub/internal/environment"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func RunRuntimeLeaseHeartbeat(ctx context.Context, store *environment.Store) {
|
|
ticker := time.NewTicker(20 * time.Second)
|
|
defer ticker.Stop()
|
|
for {
|
|
select {
|
|
case <-ctx.Done():
|
|
return
|
|
case <-ticker.C:
|
|
if err := api.ReconcileRuntimeLeases(ctx, store); err != nil && ctx.Err() == nil {
|
|
logrus.WithField("service", "control-plane").WithError(err).Warn("runtime lease reconciliation failed")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
func RunCreatorScheduler(ctx context.Context, store *creatorDomain.Store, accountStore *account.Store, environmentStore *environment.Store) {
|
|
api.RunCreatorScheduler(ctx, store, accountStore, environmentStore)
|
|
}
|