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