Пример #1
0
func main() {

	dbAddress := util.GetKeyValue("RethinkDB", "address")

	var err error
	session, err = db.Connect(db.ConnectOpts{
		Address:  dbAddress,
		Database: "travelPlanning",
	})
	if err != nil {
		log.Fatalln(err.Error())
	}
	log.Println("Connected to db on: " + dbAddress)

	tasks := mq.NewMQ()
	tasks.NewQueue("TripWorkerQueue", "Trip")
	msgs := tasks.GetMessages("TripWorkerQueue")

	forever := make(chan bool)

	go func() {
		for d := range msgs {
			var message mq.Message
			json.Unmarshal(d.Body, &message)
			processMessage(&message)
			tasks.PublishMessage(message, d.ReplyTo, d.CorrelationId, "")
		}
	}()

	log.Printf(" [*] Awaiting for requests")
	<-forever

}
Пример #2
0
func main() {
	Tasks = mq.NewMQ()
	Tasks.NewQueue("APICallbackQueue", "callback")
	CallbackMessages = Tasks.GetMessages("APICallbackQueue")

	trip := new(TripHandler)

	router := mux.NewRouter()
	router.HandleFunc("/trips", requestHandler(trip)).Methods("GET", "POST")
	router.HandleFunc("/trip/{id}", requestHandler(trip)).Methods("GET", "PUT", "DELETE")

	http.Handle("/", handlers.CORS()(router))

	log.Println("[TP-Server] Listening on 3000")

	loggedRouter := handlers.CombinedLoggingHandler(os.Stdout, router)

	http.ListenAndServe(":3000", loggedRouter)
}
Пример #3
0
func main() {
	log.Println("Connected to db on: " + util.GetKeyValue("RethinkDB", "address"))

	tasks := mq.NewMQ()
	tasks.NewQueue("UserWorkerQueue", "User")
	msgs := tasks.GetMessages("UserWorkerQueue")

	var message mq.Message

	forever := make(chan bool)

	go func() {
		for d := range msgs {
			json.Unmarshal(d.Body, &message)
			processMessage(&message)
			tasks.PublishMessage(message, d.ReplyTo, d.CorrelationId, "")
		}
	}()

	log.Printf(" [*] Awaiting for requests")
	<-forever

}