From 3f6d5d14f554a33e6e2c694c2c0f690613f3e030 Mon Sep 17 00:00:00 2001 From: trunglt251292 Date: Mon, 21 Mar 2022 09:19:46 +0700 Subject: [PATCH] [Update] Param name --- constants.go | 18 +++++++++--------- pull.go | 12 ++++++------ request.go | 12 ++++++------ struct.go | 13 +++---------- 4 files changed, 24 insertions(+), 31 deletions(-) diff --git a/constants.go b/constants.go index 7fa7ef2..16ebb38 100644 --- a/constants.go +++ b/constants.go @@ -1,17 +1,17 @@ package elasticsearch const ( - SubjectRequestProductUpsert = "elasticsearch/selly.request.product.upsert" - SubjectPullProductUpsert = "elasticsearch/selly.pull.product.upsert" - SubjectRequestProductSearch = "elasticsearch/selly.request.product.search" + SubjectRequestProductUpsert = "selly.request.product.upsert" + SubjectPullProductUpsert = "selly.pull.product.upsert" + SubjectRequestProductSearch = "selly.request.product.search" - SubjectRequestOrderUpsert = "elasticsearch/selly.request.order.upsert" - SubjectPullOrderUpsert = "elasticsearch/selly.pull.order.upsert" - SubjectRequestOrderSearch = "elasticsearch/selly.request.order.search" + SubjectRequestOrderUpsert = "selly.request.order.upsert" + SubjectPullOrderUpsert = "selly.pull.order.upsert" + SubjectRequestOrderSearch = "selly.request.order.search" - SubjectRequestUserUpsert = "elasticsearch/selly.request.order.upsert" - SubjectPullUserUpsert = "elasticsearch/selly.pull.order.upsert" - SubjectRequestUserSearch = "elasticsearch/selly.request.user.search" + SubjectRequestUserUpsert = "selly.request.user.upsert" + SubjectPullUserUpsert = "selly.pull.user.upsert" + SubjectRequestUserSearch = "selly.request.user.search" ) const ( diff --git a/pull.go b/pull.go index 4911b36..fe354bc 100644 --- a/pull.go +++ b/pull.go @@ -5,16 +5,16 @@ type Pull struct { } // ProductUpsert ... -func (Pull) ProductUpsert(query UpdateDataPayload) (bool, error) { - return publishWithJetStream(JetStreamSearchService, SubjectPullProductUpsert, toBytes(query)) +func (Pull) ProductUpsert(payload Payload) (bool, error) { + return publishWithJetStream(JetStreamSearchService, SubjectPullProductUpsert, toBytes(payload)) } // UserUpsert ... -func (Pull) UserUpsert(query UpdateDataPayload) (bool, error) { - return publishWithJetStream(JetStreamSearchService, SubjectPullUserUpsert, toBytes(query)) +func (Pull) UserUpsert(payload Payload) (bool, error) { + return publishWithJetStream(JetStreamSearchService, SubjectPullUserUpsert, toBytes(payload)) } // OrderUpsert ... -func (Pull) OrderUpsert(query UpdateDataPayload) (bool, error) { - return publishWithJetStream(JetStreamSearchService, SubjectPullOrderUpsert, toBytes(query)) +func (Pull) OrderUpsert(payload Payload) (bool, error) { + return publishWithJetStream(JetStreamSearchService, SubjectPullOrderUpsert, toBytes(payload)) } diff --git a/request.go b/request.go index d67b5c3..3693532 100644 --- a/request.go +++ b/request.go @@ -10,8 +10,8 @@ func (Request) ProductSearch(query ESQuery) (*Response, error) { } // ProductUpsert ... -func (Request) ProductUpsert(query UpdateDataPayload) (*Response, error) { - return requestNats(SubjectRequestProductUpsert, toBytes(query)) +func (Request) ProductUpsert(payload Payload) (*Response, error) { + return requestNats(SubjectRequestProductUpsert, toBytes(payload)) } // UserSearch ... @@ -20,8 +20,8 @@ func (Request) UserSearch(query ESQuery) (*Response, error) { } // UserUpsert ... -func (Request) UserUpsert(query UpdateDataPayload) (*Response, error) { - return requestNats(SubjectRequestUserUpsert, toBytes(query)) +func (Request) UserUpsert(payload Payload) (*Response, error) { + return requestNats(SubjectRequestUserUpsert, toBytes(payload)) } // OrderSearch ... @@ -30,6 +30,6 @@ func (Request) OrderSearch(query ESQuery) (*Response, error) { } // OrderUpsert ... -func (Request) OrderUpsert(query UpdateDataPayload) (*Response, error) { - return requestNats(SubjectRequestOrderUpsert, toBytes(query)) +func (Request) OrderUpsert(payload Payload) (*Response, error) { + return requestNats(SubjectRequestOrderUpsert, toBytes(payload)) } diff --git a/struct.go b/struct.go index 602f8a8..504b9b5 100644 --- a/struct.go +++ b/struct.go @@ -19,20 +19,13 @@ type Response struct { Message string `json:"message"` } -// SyncData -// Payload for sync data to service es -type SyncData struct { +// Payload ... +// payload for sync data to service es +type Payload struct { Index string Data []byte } -// UpdateDataPayload -// Payload for insert or update document -type UpdateDataPayload struct { - Index string - Body []byte -} - // DeleteDataPayload // Payload for delete document type DeleteDataPayload struct {