title: Peekable Queue in Golang
body: <p>I am trying to design a mechanism to allow cooperation of many processes – goroutines. There are two classes of processes – providers and users. Providers put “bids” for their services into a queue and users take waiting bids and start working with providers. However, a user may not like a bid and then two things should happen:</p>
  
  <ul>
  <li>This bid should return to the queue. It should be placed at the beginning of the queue </li>
  <li>The user should be given the next bid in the queue </li>
  </ul>
  
  <p>Ideally, I would like to avoid a central process that coordinates the communication between providers and users. 
  Another way of thinking about this problem is to imagine a “peekable” queue or channel. A concept similar to the way AWS Kinesis works. A reader can get an access to “peek” into the head of the queue. As this reader is peeking, no other readers can see the item. It the reader likes the item, then it removes it from the queue. If not the reader releases the lock on the item and another reader can peek. </p>
  
  <p>Any ideas how to best implement this behavior in Go using channels and goroutines? </p>