MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / newId

Method newId

worker/queue.go:291–300  ·  view source on GitHub ↗

newId generates a random unique task ID. logMu must be acquired before calling this function. The format of this is: 32 bits: raft ID 32 bits: random number

()

Source from the content-addressed store, hash-verified

289// 32 bits: raft ID
290// 32 bits: random number
291func (t *tasks) newId() uint64 {
292 myRaftId := State.WALstore.Uint(raftwal.RaftId)
293 for {
294 id := myRaftId<<32 | uint64(t.rng.Uint32())
295 // z.Tree cannot store 0 or math.MaxUint64. Check that id is unique.
296 if id != 0 && id != math.MaxUint64 && t.log.Get(id) == 0 {
297 return id
298 }
299 }
300}
301
302type taskRequest struct {
303 id uint64

Callers 1

enqueueMethod · 0.95

Calls 2

GetMethod · 0.65
UintMethod · 0.45

Tested by

no test coverage detected