mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 21:40:18 +02:00
* feat: added cron for updating feature flags on interval * feat: added logic for updating seats in monitor * feat: updated sync handler for using prime sync endpoint * feat: added instance initialization on monitor boot * chore: added new vars for monitor * fix: license seats purchase validation flow * dev: update invite return response * remove: workspace license task to avoid creation of duplicate licenses * dev: add more seats flow. * fix: resync licenses * chore: subscription portal endpoint --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com>
42 lines
1.5 KiB
Go
42 lines
1.5 KiB
Go
package prime_cron
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/go-co-op/gocron/v2"
|
|
"github.com/makeplane/plane-ee/monitor/lib/healthcheck"
|
|
)
|
|
|
|
type HealthCheckCallback func(serviceStatuses []*healthcheck.HealthCheckStatus, err []*error)
|
|
|
|
// Registers a new healthcheck job in the prime scheduler, the function takes
|
|
// the context of the parent process, defination provided by the gocron and also
|
|
// takes in a healthcheck callback, which will be fired when all the status have
|
|
// been accumilated and are ready to be sent.
|
|
func (s *PrimeScheduler) RegisterNewHealthCheckJob(ctx context.Context, defination gocron.JobDefinition, healthCheckCallback HealthCheckCallback) {
|
|
healthCheckTask := gocron.NewTask(func() {
|
|
healthCheckHandler := healthcheck.NewHealthCheckHandler()
|
|
healthCheckCtx, cancel := context.WithCancel(ctx)
|
|
defer cancel()
|
|
options := healthcheck.HealthCheckOptions{
|
|
MaxRetries: 5,
|
|
ConfirmTries: 3,
|
|
TimeoutDuration: 5 * time.Second,
|
|
RetryDuration: 2 * time.Second,
|
|
}
|
|
accStatus := healthCheckHandler.GetAccumilatedHealthCheck(healthCheckCtx, options)
|
|
healthCheckCallback(accStatus.Statuses, accStatus.Errors)
|
|
})
|
|
|
|
s.RegisterJob(defination, healthCheckTask, gocron.WithName("Service Health Check"))
|
|
}
|
|
|
|
func (s *PrimeScheduler) RegisterLicenseRefreshJob(ctx context.Context, defination gocron.JobDefinition, task func(ctx context.Context)) {
|
|
licenseRefreshTask := gocron.NewTask(func() {
|
|
task(context.Background())
|
|
})
|
|
|
|
s.RegisterJob(defination, licenseRefreshTask, gocron.WithName("Service License Refresh"))
|
|
}
|