internal/jobs: renamings
Rename the package to "jobs" so we can use "job" as a variable name.
Rename New to NewJob.
Rename Job.NumCached to Job.NumSkipped.
Change-Id: I1d2a4fe97e1428a380ff915adb58648c360eed1e
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/495759
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
diff --git a/internal/job/firestore.go b/internal/jobs/firestore.go
similarity index 99%
rename from internal/job/firestore.go
rename to internal/jobs/firestore.go
index 9da86ce..4b288d5 100644
--- a/internal/job/firestore.go
+++ b/internal/jobs/firestore.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package job
+package jobs
import (
"context"
diff --git a/internal/job/firestore_test.go b/internal/jobs/firestore_test.go
similarity index 95%
rename from internal/job/firestore_test.go
rename to internal/jobs/firestore_test.go
index 7e42929..88d4cbc 100644
--- a/internal/job/firestore_test.go
+++ b/internal/jobs/firestore_test.go
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-package job
+package jobs
import (
"context"
@@ -35,7 +35,7 @@
}
tm := time.Date(2001, 02, 03, 4, 5, 6, 0, time.UTC)
- job := New("user", tm, "analysis/enqueue?min=10")
+ job := NewJob("user", tm, "analysis/enqueue?min=10")
// Make sure the job doesn't exist. Delete doesn't fail
// in that case.
diff --git a/internal/job/job.go b/internal/jobs/job.go
similarity index 75%
rename from internal/job/job.go
rename to internal/jobs/job.go
index cc6f771..40cac63 100644
--- a/internal/job/job.go
+++ b/internal/jobs/job.go
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// Package job supports jobs, collections of enqueued tasks.
-package job
+// Package jobs supports jobs, which are collections of enqueued tasks.
+package jobs
import (
"time"
@@ -18,14 +18,14 @@
// Counts of tasks.
NumEnqueued int // Written by enqueue endpoint.
NumStarted int // Incremented at the start of a scan.
- NumCached int // Previously run, stored in BigQuery.
+ NumSkipped int // Previously run, stored in BigQuery.
NumFailed int // The HTTP request failed (status != 200)
NumErrored int // The HTTP request succeeded, but the scan resulted in an error.
NumSucceeded int
}
-// New creates a new Job.
-func New(user string, start time.Time, url string) *Job {
+// NewJob creates a new Job.
+func NewJob(user string, start time.Time, url string) *Job {
return &Job{
User: user,
StartedAt: start,
@@ -35,6 +35,7 @@
const startTimeFormat = "060102-030405" // YYMMDD-HHMMSS, UTC
+// ID returns a unique identifier for a job which can serve as a database key.
func (j *Job) ID() string {
return j.User + "-" + j.StartedAt.In(time.UTC).Format(startTimeFormat)
}