internal/{jobs,worker}: remove ability to delete a job
The worker never needs to delete jobs. If for some reason we really
want to, we can do it from the Firestore console.
Change-Id: Ia47d9a9ec97c585c10a6a09b802d7b820ffad8a3
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/499921
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
diff --git a/internal/jobs/firestore.go b/internal/jobs/firestore.go
index 6f6a2bc..b7ed1d6 100644
--- a/internal/jobs/firestore.go
+++ b/internal/jobs/firestore.go
@@ -52,8 +52,9 @@
return err
}
-// DeleteJob deletes the job with the given ID. It does not return an error if the job doesn't exist.
-func (d *DB) DeleteJob(ctx context.Context, id string) (err error) {
+// deleteJob deletes the job with the given ID. It does not return an error if the job doesn't exist.
+// This function is unexported because the worker never deletes jobs.
+func (d *DB) deleteJob(ctx context.Context, id string) (err error) {
defer derrors.Wrap(&err, "job.DB.DeleteJob(%s)", id)
_, err = d.jobRef(id).Delete(ctx)
return err
diff --git a/internal/jobs/firestore_test.go b/internal/jobs/firestore_test.go
index 3c9bdb0..346598b 100644
--- a/internal/jobs/firestore_test.go
+++ b/internal/jobs/firestore_test.go
@@ -39,7 +39,7 @@
// Make sure the job doesn't exist. Delete doesn't fail
// in that case.
- must(db.DeleteJob(ctx, job.ID()))
+ must(db.deleteJob(ctx, job.ID()))
// Create a new job.
must(db.CreateJob(ctx, job))
@@ -72,7 +72,7 @@
// Create another job, then list both.
job2 := NewJob("user2", tm.Add(24*time.Hour), "url2")
- must(db.DeleteJob(ctx, job2.ID()))
+ must(db.deleteJob(ctx, job2.ID()))
must(db.CreateJob(ctx, job2))
var got2 []*Job
diff --git a/internal/worker/jobs.go b/internal/worker/jobs.go
index 4f7a09d..7c56abb 100644
--- a/internal/worker/jobs.go
+++ b/internal/worker/jobs.go
@@ -9,8 +9,6 @@
// TODO:
// jobs/list list all jobs
// jobs/cancel?jobid=xxx cancel a job
-// jobs/delete?jobid=xxx delete a job
-// jobs/deleteOlder?dur=xxx delete jobs older than a duration
package worker
@@ -43,7 +41,6 @@
type jobDB interface {
CreateJob(ctx context.Context, j *jobs.Job) error
- DeleteJob(ctx context.Context, id string) error
GetJob(ctx context.Context, id string) (*jobs.Job, error)
UpdateJob(ctx context.Context, id string, f func(*jobs.Job) error) error
ListJobs(context.Context, func(*jobs.Job, time.Time) error) error