From f0bb9cf00d25e3cb33859e6af1aae98f79d4bf50 Mon Sep 17 00:00:00 2001 From: Piotr Biernat Date: Wed, 30 Sep 2020 22:12:50 +0200 Subject: [PATCH] [fix] Renamed amqp var and make it public --- handler/articles.go | 4 ++-- handler/base.go | 4 ++-- main.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/handler/articles.go b/handler/articles.go index 775430c..b5259f8 100644 --- a/handler/articles.go +++ b/handler/articles.go @@ -43,7 +43,7 @@ type ArticleGenerateHeavyPDFMessage struct { func (h *ArticlesHandler) testRabbit(c echo.Context) error { log.Println("test rabbit publish method calling...") - q := h.amqp.DeclareQueue("article_queue_test") + q := h.Queue.DeclareQueue("article_queue_test") m := ArticleGenerateHeavyPDFMessage{ Title: "Test title", Content: "Lorem ipsum dolor sit amet", @@ -51,7 +51,7 @@ func (h *ArticlesHandler) testRabbit(c echo.Context) error { } body, _ := h.JSONEncode(m) - h.amqp.Publish(q.Name, body, "application/json") + h.Queue.Publish(q.Name, body, "application/json") response := "Please wait until generating pdf or some other long task (in rabbitMQ queue) done" return c.JSON(http.StatusOK, response) diff --git a/handler/base.go b/handler/base.go index dde1e04..32c7472 100644 --- a/handler/base.go +++ b/handler/base.go @@ -29,16 +29,16 @@ func DeserializeFromRequest(request *http.Request, output interface{}) { // BaseHandler type type BaseHandler struct { + Queue *queue.AMQP db *database.MongoDb - amqp *queue.AMQP validator *validator.Validate } // NewHandler Create BaseHandler instance func NewHandler() *BaseHandler { return &BaseHandler{ + Queue: queue.New(), db: database.New(), - amqp: queue.New(), validator: validator.New(), } } diff --git a/main.go b/main.go index a6b5ef2..db02c3d 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( var port = ":8000" func main() { - // Echo fw setup + // framework setup e := echo.New() e.Use(middleware.Logger()) e.Use(middleware.Recover())