2026-04-06 15:48:37 +05:30
|
|
|
// Copyright IBM Corp. 2020, 2026
|
2021-11-01 09:07:56 -07:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-02-02 17:15:17 -08:00
|
|
|
|
2021-11-01 09:07:56 -07:00
|
|
|
package plugin
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-10-12 10:33:41 -07:00
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/db"
|
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/errors"
|
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/kms"
|
|
|
|
|
"repo.anhonesthost.net/CyberCoveLLC/threshold/internal/scheduler"
|
|
|
|
|
plgpb "repo.anhonesthost.net/CyberCoveLLC/threshold/sdk/pbs/plugin"
|
2021-11-01 09:07:56 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// RegisterJobs registers plugin host related jobs with the provided scheduler.
|
|
|
|
|
func RegisterJobs(ctx context.Context, scheduler *scheduler.Scheduler, r db.Reader, w db.Writer, kms *kms.Kms, plgm map[string]plgpb.HostPluginServiceClient) error {
|
|
|
|
|
const op = "plugin.RegisterJobs"
|
|
|
|
|
setSyncJob, err := newSetSyncJob(ctx, r, w, kms, plgm)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.Wrap(ctx, err, op)
|
|
|
|
|
}
|
|
|
|
|
if err = scheduler.RegisterJob(ctx, setSyncJob); err != nil {
|
|
|
|
|
return errors.Wrap(ctx, err, op, errors.WithMsg("set sync job"))
|
|
|
|
|
}
|
|
|
|
|
orphanedHostCleanupJob, err := newOrphanedHostCleanupJob(ctx, r, w, kms)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return errors.Wrap(ctx, err, op)
|
|
|
|
|
}
|
|
|
|
|
if err = scheduler.RegisterJob(ctx, orphanedHostCleanupJob); err != nil {
|
|
|
|
|
return errors.Wrap(ctx, err, op, errors.WithMsg("orphaned host cleanup job"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|