MCPcopy Create free account
hub / github.com/beeker1121/goque / EnqueueObject

Method EnqueueObject

queue.go:99–107  ·  view source on GitHub ↗

EnqueueObject is a helper function for Enqueue that accepts any value type, which is then encoded into a byte slice using encoding/gob. Objects containing pointers with zero values will decode to nil when using this function. This is due to how the encoding/gob package works. Because of this, you s

(value interface{})

Source from the content-addressed store, hash-verified

97// package works. Because of this, you should only use this function
98// to encode simple types.
99func (q *Queue) EnqueueObject(value interface{}) (*Item, error) {
100 var buffer bytes.Buffer
101 enc := gob.NewEncoder(&buffer)
102 if err := enc.Encode(value); err != nil {
103 return nil, err
104 }
105
106 return q.Enqueue(buffer.Bytes())
107}
108
109// EnqueueObjectAsJSON is a helper function for Enqueue that accepts
110// any value type, which is then encoded into a JSON byte slice using

Callers 4

TestQueueUpdateObjectFunction · 0.45
Example_objectFunction · 0.45

Calls 1

EnqueueMethod · 0.95

Tested by 4

TestQueueUpdateObjectFunction · 0.36
Example_objectFunction · 0.36