From eb2d9fe754ccfa3bbfea03b9e1dfe623162e89a4 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Wed, 30 Mar 2022 19:46:42 +0700 Subject: [PATCH] [Update] Request nats --- constants.go | 30 ++++++++++++++++-------------- request.go | 21 ++++++++++++++++++--- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/constants.go b/constants.go index 67631fd..6ffbd01 100644 --- a/constants.go +++ b/constants.go @@ -1,23 +1,25 @@ package elasticsearch const ( - SubjectRequestProductUpsert = "selly.request.product.upsert" - SubjectPullProductUpsert = "selly.pull.product.upsert" - SubjectRequestProductSearch = "selly.request.product.search" + SubjectRequestProductUpsert = "selly.request.product.upsert" + SubjectPullProductUpsert = "selly.pull.product.upsert" + SubjectRequestProductSearch = "selly.request.product.search" + SubjectRequestProductCreateIndex = "selly.request.product.create_index" - SubjectRequestOrderUpsert = "selly.request.order.upsert" - SubjectPullOrderUpsert = "selly.pull.order.upsert" - SubjectRequestOrderSearch = "selly.request.order.search" + SubjectRequestOrderUpsert = "selly.request.order.upsert" + SubjectPullOrderUpsert = "selly.pull.order.upsert" + SubjectRequestOrderSearch = "selly.request.order.search" + SubjectRequestOrderCreateIndex = "selly.request.order.create_index" - SubjectRequestUserUpsert = "selly.request.user.upsert" - SubjectPullUserUpsert = "selly.pull.user.upsert" - SubjectRequestUserSearch = "selly.request.user.search" + SubjectRequestKeywordUpsert = "selly.request.keyword.upsert" + SubjectPullKeywordUpsert = "selly.pull.keyword.upsert" + SubjectRequestKeywordSearch = "selly.request.keyword.search" + SubjectRequestKeywordCreateIndex = "selly.request.order.create_index" - SubjectRequestKeywordUpsert = "selly.request.keyword.upsert" - SubjectPullKeywordUpsert = "selly.pull.keyword.upsert" - SubjectRequestKeywordSearch = "selly.request.keyword.search" - - SubjectRequestCreateIndex = "selly.request.es.create_index" + SubjectRequestUserUpsert = "selly.request.user.upsert" + SubjectPullUserUpsert = "selly.pull.user.upsert" + SubjectRequestUserSearch = "selly.request.user.search" + SubjectRequestUserCreateIndex = "selly.request.user.create_index" ) const ( diff --git a/request.go b/request.go index 2a7e4bd..8a13a80 100644 --- a/request.go +++ b/request.go @@ -14,6 +14,11 @@ func (Request) ProductUpsert(payload Payload) (*Response, error) { return requestNats(SubjectRequestProductUpsert, toBytes(payload)) } +// ProductCreateIndex ... +func (Request) ProductCreateIndex() (*Response, error) { + return requestNats(SubjectRequestProductCreateIndex, toBytes(Payload{})) +} + // UserSearch ... func (Request) UserSearch(query ESQuery) (*Response, error) { return requestNats(SubjectRequestUserSearch, toBytes(query)) @@ -24,6 +29,11 @@ func (Request) UserUpsert(payload Payload) (*Response, error) { return requestNats(SubjectRequestUserUpsert, toBytes(payload)) } +// UserCreateIndex ... +func (Request) UserCreateIndex() (*Response, error) { + return requestNats(SubjectRequestUserCreateIndex, toBytes(Payload{})) +} + // OrderSearch ... func (Request) OrderSearch(query ESQuery) (*Response, error) { return requestNats(SubjectRequestOrderSearch, toBytes(query)) @@ -34,6 +44,11 @@ func (Request) OrderUpsert(payload Payload) (*Response, error) { return requestNats(SubjectRequestOrderUpsert, toBytes(payload)) } +// OrderCreateIndex ... +func (Request) OrderCreateIndex() (*Response, error) { + return requestNats(SubjectRequestOrderCreateIndex, toBytes(Payload{})) +} + // KeywordSearch ... func (Request) KeywordSearch(query ESQuery) (*Response, error) { return requestNats(SubjectRequestKeywordSearch, toBytes(query)) @@ -44,7 +59,7 @@ func (Request) KeywordUpsert(payload Payload) (*Response, error) { return requestNats(SubjectRequestKeywordUpsert, toBytes(payload)) } -// CreateIndex ... -func (Request) CreateIndex(payload Payload) (*Response, error) { - return requestNats(SubjectRequestCreateIndex, toBytes(payload)) +// KeywordCreateIndex ... +func (Request) KeywordCreateIndex() (*Response, error) { + return requestNats(SubjectRequestKeywordCreateIndex, toBytes(Payload{})) }