Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit 01f1180

Browse files
committed
Merge commit "fix: queue: switch from using a time based counter to a monotonic one"
2 parents ed88972 + 071d037 commit 01f1180

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
os:
22
- linux
3+
- windows
34

45
language: go
56

queue/queue.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package queue
33
import (
44
"context"
55
"fmt"
6-
"time"
7-
86
cid "github.com/ipfs/go-cid"
97
datastore "github.com/ipfs/go-datastore"
108
namespace "github.com/ipfs/go-datastore/namespace"
@@ -29,6 +27,8 @@ type Queue struct {
2927
enqueue chan cid.Cid
3028
close context.CancelFunc
3129
closed chan struct{}
30+
31+
counter int
3232
}
3333

3434
// NewQueue creates a queue for cids
@@ -117,7 +117,8 @@ func (q *Queue) work() {
117117

118118
select {
119119
case toQueue := <-q.enqueue:
120-
keyPath := fmt.Sprintf("%d/%s", time.Now().UnixNano(), c.String())
120+
keyPath := fmt.Sprintf("%063d/%s", q.counter, c.String())
121+
q.counter++
121122
nextKey := datastore.NewKey(keyPath)
122123

123124
if err := q.ds.Put(q.ctx, nextKey, toQueue.Bytes()); err != nil {

0 commit comments

Comments
 (0)