* Move the session cleanup job logic into the session package. This is part of a broader effort to more narrowly define the purpose of the internal/server directory to be for interacting with servers themselves. Future changes will continue to remove things from this directory until the purpose of the directory is clearly working primarily with the boundary servers resource.
25 lines
726 B
Go
25 lines
726 B
Go
package session
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/hashicorp/boundary/internal/db"
|
|
"github.com/hashicorp/boundary/internal/scheduler"
|
|
)
|
|
|
|
// RegisterJobs registers plugin host related jobs with the provided scheduler.
|
|
func RegisterJobs(ctx context.Context, scheduler *scheduler.Scheduler, w db.Writer, gracePeriod time.Duration) error {
|
|
const op = "session.RegisterJobs"
|
|
sessionConnectionCleanupJob, err := newSessionConnectionCleanupJob(w, gracePeriod)
|
|
if err != nil {
|
|
return fmt.Errorf("error creating session cleanup job: %w", err)
|
|
}
|
|
if err = scheduler.RegisterJob(ctx, sessionConnectionCleanupJob); err != nil {
|
|
return fmt.Errorf("error registering session cleanup job: %w", err)
|
|
}
|
|
|
|
return nil
|
|
}
|