Skip to content

Instantly share code, notes, and snippets.

@soheilhy
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soheilhy/bd23ac75319149d61a86 to your computer and use it in GitHub Desktop.
Save soheilhy/bd23ac75319149d61a86 to your computer and use it in GitHub Desktop.
An incomplete, inefficient implementation of EnQHanlder.Rcv
const (
// Dictionary names.
active = "active"
dequed = "dequed"
)
func (h EnQHandler) Rcv(msg beehive.Msg, ctx beehive.RcvContext) error {
// TODO: assign a unique ID.
enq := msg.Data().(Enque)
dict := ctx.Dict(active)
key := string(enq.Task.Queue)
var tasks []Task
if val, err := dict.Get(key); err == nil {
tasks = val.([]Task)
}
tasks = append(tasks, enq.Task)
return dict.Put(key, tasks)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment