Skip to content

Instantly share code, notes, and snippets.

@soheilhy soheilhy/main.go
Last active Aug 29, 2015

Embed
What would you like to do?
Incomplete TaskQ/main()
func main() {
h := beehive.NewHive()
taskq.RegisterTaskQ(h)
go h.Start()
defer h.Stop()
q := taskq.Queue("MyQueue")
b := "copy f1 to f2"
enq := taskq.Enque{Task: taskq.Task{Queue: q, Body: []byte(b)}}
if _, err := h.Sync(context.TODO(), enq); err != nil {
panic(err)
}
deq := taskq.Deque{Queue: q}
var t taskq.Task
if res, err := h.Sync(context.TODO(), deq); err != nil {
panic(err)
} else {
t = res.(taskq.Task)
}
fmt.Printf("processed task #%v: %s\n", t.ID, string(t.Body))
ack := taskq.Ack{ID: t.ID, Queue: q}
if _, err := h.Sync(context.TODO(), ack); err != nil {
panic(err)
}
fmt.Printf("acked task #%v: %s\n", t.ID, string(t.Body))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.