-
Notifications
You must be signed in to change notification settings - Fork 175
/
jobs.go
43 lines (33 loc) · 1.6 KB
/
jobs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package operation
import (
"github.com/dgraph-io/badger/v2"
"github.com/onflow/flow-go/model/flow"
)
func RetrieveJobLatestIndex(queue string, index *uint64) func(*badger.Txn) error {
return retrieve(makePrefix(codeJobQueuePointer, queue), index)
}
func InitJobLatestIndex(queue string, index uint64) func(*badger.Txn) error {
return insert(makePrefix(codeJobQueuePointer, queue), index)
}
func SetJobLatestIndex(queue string, index uint64) func(*badger.Txn) error {
return update(makePrefix(codeJobQueuePointer, queue), index)
}
// RetrieveJobAtIndex returns the entity at the given index
func RetrieveJobAtIndex(queue string, index uint64, entity *flow.Identifier) func(*badger.Txn) error {
return retrieve(makePrefix(codeJobQueue, queue, index), entity)
}
// InsertJobAtIndex insert an entity ID at the given index
func InsertJobAtIndex(queue string, index uint64, entity flow.Identifier) func(*badger.Txn) error {
return insert(makePrefix(codeJobQueue, queue, index), entity)
}
// RetrieveProcessedIndex returns the processed index for a job consumer
func RetrieveProcessedIndex(jobName string, processed *uint64) func(*badger.Txn) error {
return retrieve(makePrefix(codeJobConsumerProcessed, jobName), processed)
}
func InsertProcessedIndex(jobName string, processed uint64) func(*badger.Txn) error {
return insert(makePrefix(codeJobConsumerProcessed, jobName), processed)
}
// SetProcessedIndex updates the processed index for a job consumer with given index
func SetProcessedIndex(jobName string, processed uint64) func(*badger.Txn) error {
return update(makePrefix(codeJobConsumerProcessed, jobName), processed)
}