Skip to content

Commit 7d28278

Browse files
authored
Rename Job & Count UUID to Partition ID (#28)
Renames the uuid and job_uuid fields to partition ID. This is the more correct name as this value is not a true UUID, is in-fact a partition ID, and doesn't need to be globally unique. ```shell $ grep -nir . -e "uuid" ./go.sum:98:github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= ./go.sum:167:github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= $ ``` Signed-off-by: joshvanl <[email protected]>
1 parent 5021035 commit 7d28278

File tree

15 files changed

+200
-189
lines changed

15 files changed

+200
-189
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Leadership keys are associated with an ETCD lease of 20s TTL to prevent stale le
8484
## Counter
8585

8686
An associated `counters` key is used to track the current state of a job that is scheduled.
87-
It includes the last trigger time (if triggered), the number of times the job has been triggered, and the UUID of the associated job with the same name.
87+
It includes the last trigger time (if triggered), the number of times the job has been triggered, and the Partition ID of the associated job with the same name.
8888
Counters are lazily deleted in bulk by a garbage collector that runs every 180s in an effort to reduce pressure of jobs triggering.
8989

9090
The scheduler will never miss triggering jobs.

api/counter.pb.go

Lines changed: 11 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/job.pb.go

Lines changed: 45 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cron_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ func Test_schedule(t *testing.T) {
447447
Begin: &api.JobStored_DueTime{
448448
DueTime: timestamppb.New(now),
449449
},
450-
Uuid: 123,
450+
PartitionId: 123,
451451
Job: &api.Job{
452452
DueTime: ptr.Of(now.Format(time.RFC3339)),
453453
},
@@ -518,15 +518,15 @@ func Test_schedule(t *testing.T) {
518518
Begin: &api.JobStored_DueTime{
519519
DueTime: timestamppb.New(now),
520520
},
521-
Uuid: 123,
521+
PartitionId: 123,
522522
Job: &api.Job{
523523
DueTime: ptr.Of(now.Format(time.RFC3339)),
524524
},
525525
}
526526
counter := &api.Counter{
527-
LastTrigger: nil,
528-
Count: 0,
529-
JobUuid: 123,
527+
LastTrigger: nil,
528+
Count: 0,
529+
JobPartitionId: 123,
530530
}
531531

532532
jobBytes, err := proto.Marshal(job)
@@ -599,15 +599,15 @@ func Test_schedule(t *testing.T) {
599599
Begin: &api.JobStored_DueTime{
600600
DueTime: timestamppb.New(now),
601601
},
602-
Uuid: 123,
602+
PartitionId: 123,
603603
Job: &api.Job{
604604
DueTime: ptr.Of(now.Format(time.RFC3339)),
605605
},
606606
}
607607
counter := &api.Counter{
608-
LastTrigger: timestamppb.New(now),
609-
Count: 1,
610-
JobUuid: 123,
608+
LastTrigger: timestamppb.New(now),
609+
Count: 1,
610+
JobPartitionId: 123,
611611
}
612612

613613
jobBytes, err := proto.Marshal(job)

internal/counter/counter.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func New(ctx context.Context, opts Options) (*Counter, bool, error) {
8383
client: opts.Client,
8484
schedule: opts.Schedule,
8585
job: opts.Job,
86-
count: &api.Counter{JobUuid: opts.Job.GetUuid()},
86+
count: &api.Counter{JobPartitionId: opts.Job.GetPartitionId()},
8787
yard: opts.Yard,
8888
collector: opts.Collector,
8989
triggerRequest: &api.TriggerRequest{
@@ -105,10 +105,10 @@ func New(ctx context.Context, opts Options) (*Counter, bool, error) {
105105
return nil, false, err
106106
}
107107

108-
// If the job UUID is the same, recover the counter state, else we start
109-
// again.
110-
if count.GetJobUuid() != opts.Job.GetUuid() {
111-
count = &api.Counter{JobUuid: opts.Job.GetUuid()}
108+
// If the job partition ID is the same, recover the counter state, else we
109+
// start again.
110+
if count.GetJobPartitionId() != opts.Job.GetPartitionId() {
111+
count = &api.Counter{JobPartitionId: opts.Job.GetPartitionId()}
112112
b, err := proto.Marshal(count)
113113
if err != nil {
114114
return nil, false, err

0 commit comments

Comments
 (0)