func()

in persistence/queue.go [47:65]


func (vq *valueQueue) Peek(obj interface{}) error {
	var queue []json.RawMessage
	// Grab the value's associated persistence read lock and load the queue
	vq.value.mutex().RLock()
	err := vq.value.load(&queue)
	vq.value.mutex().RUnlock()
	if err != nil {
		return err
	}
	// If the queue exists but is somehow empty, we return ErrNotFound
	if len(queue) == 0 {
		return ErrNotFound
	}
	// Unmarshal the front of the queue and store it in obj.
	if err := json.Unmarshal(queue[0], obj); err != nil {
		return err
	}
	return nil
}