Skip to content

Commit

Permalink
refactor: delete cron from controller
Browse files Browse the repository at this point in the history
The next step will be creating a new service that executes cron jobs by
consuming PullSchema.
  • Loading branch information
alecthomas committed Nov 13, 2024
1 parent 852c560 commit 76652ca
Show file tree
Hide file tree
Showing 30 changed files with 15 additions and 1,775 deletions.
16 changes: 1 addition & 15 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/TBD54566975/ftl/backend/controller/artefacts"
"github.com/TBD54566975/ftl/backend/controller/async"
"github.com/TBD54566975/ftl/backend/controller/console"
"github.com/TBD54566975/ftl/backend/controller/cronjobs"
"github.com/TBD54566975/ftl/backend/controller/dal"
dalmodel "github.com/TBD54566975/ftl/backend/controller/dal/model"
"github.com/TBD54566975/ftl/backend/controller/dsn"
Expand Down Expand Up @@ -230,7 +229,6 @@ type Service struct {
sm *cf.Manager[configuration.Secrets]

tasks *scheduledtask.Scheduler
cronJobs *cronjobs.Service
pubSub *pubsub.Service
registry *artefacts.Service
timeline *timeline.Service
Expand Down Expand Up @@ -301,9 +299,7 @@ func New(
svc.timeline = timelineSvc
pubSub := pubsub.New(ctx, conn, encryption, optional.Some[pubsub.AsyncCallListener](svc), timelineSvc)
svc.pubSub = pubSub
cronSvc := cronjobs.New(ctx, key, svc.config.Advertise.Host, encryption, timelineSvc, conn)
svc.cronJobs = cronSvc
svc.dal = dal.New(ctx, conn, encryption, pubSub, cronSvc)
svc.dal = dal.New(ctx, conn, encryption, pubSub)

svc.deploymentLogsSink = newDeploymentLogsSink(ctx, timelineSvc)

Expand Down Expand Up @@ -603,11 +599,6 @@ func (s *Service) ReplaceDeploy(ctx context.Context, c *connect.Request[ftlv1.Re
}
}

err = s.cronJobs.CreatedOrReplacedDeloyment(ctx)
if err != nil {
return nil, fmt.Errorf("could not schedule cron jobs: %w", err)
}

return connect.NewResponse(&ftlv1.ReplaceDeployResponse{}), nil
}

Expand Down Expand Up @@ -1482,11 +1473,6 @@ func (s *Service) finaliseAsyncCall(ctx context.Context, tx *dal.DAL, call *dal.

// Allow for handling of completion based on origin
switch origin := call.Origin.(type) {
case async.AsyncOriginCron:
if err := s.cronJobs.OnJobCompletion(ctx, origin.CronJobKey, failed); err != nil {
return fmt.Errorf("failed to finalize cron async call: %w", err)
}

case async.AsyncOriginPubSub:
if err := s.pubSub.OnCallCompletion(ctx, tx.Connection, origin, failed, isFinalResult); err != nil {
return fmt.Errorf("failed to finalize pubsub async call: %w", err)
Expand Down
248 changes: 0 additions & 248 deletions backend/controller/cronjobs/cronjobs.go

This file was deleted.

77 changes: 0 additions & 77 deletions backend/controller/cronjobs/cronjobs_integration_test.go

This file was deleted.

Loading

0 comments on commit 76652ca

Please sign in to comment.