Skip to content

Instantly share code, notes, and snippets.

@featalion
Created February 10, 2015 00:37
Show Gist options
  • Select an option

  • Save featalion/7dcbd3952d9c929bf14a to your computer and use it in GitHub Desktop.

Select an option

Save featalion/7dcbd3952d9c929bf14a to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/iron-io/iron_go/config"
"github.com/iron-io/iron_go/mq"
)
func main() {
conf := config.Presets["mq"]
conf.Token = "TOKEN"
conf.ProjectId = "PROJECT_ID"
q := mq.ConfigNew("test-timeout-error", &conf)
ids, err := q.PushStrings("first-msg", "second-msg", "third-msg")
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Msgs IDs:", ids)
msgs, err := q.GetNWithTimeout(3, 600)
if err != nil {
fmt.Println("Error:", err)
return
}
for _, msg := range msgs {
fmt.Println("Msg ID:", msg.Id)
err = msg.Delete()
if err != nil {
fmt.Println("Error:", err)
return
}
}
msgs, err = q.GetNWithTimeout(3, 600)
if err != nil {
fmt.Println("Error:", err)
return
}
fmt.Println("Msgs:", msgs)
}
// EXAMPLE OUTPUT:
// Msgs IDs: [6114008438756267800 6114008438756267801 6114008438756267802]
// Msg ID: 6114008438756267800
// Msg ID: 6114008438756267801
// Msg ID: 6114008438756267802
// Msgs: []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment