[Update] Define method #5
18
constants.go
18
constants.go
|
@ -1,17 +1,17 @@
|
||||||
package elasticsearch
|
package elasticsearch
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SubjectRequestProductUpsert = "elasticsearch/selly.request.product.upsert"
|
SubjectRequestProductUpsert = "selly.request.product.upsert"
|
||||||
SubjectPullProductUpsert = "elasticsearch/selly.pull.product.upsert"
|
SubjectPullProductUpsert = "selly.pull.product.upsert"
|
||||||
SubjectRequestProductSearch = "elasticsearch/selly.request.product.search"
|
SubjectRequestProductSearch = "selly.request.product.search"
|
||||||
|
|
||||||
SubjectRequestOrderUpsert = "elasticsearch/selly.request.order.upsert"
|
SubjectRequestOrderUpsert = "selly.request.order.upsert"
|
||||||
SubjectPullOrderUpsert = "elasticsearch/selly.pull.order.upsert"
|
SubjectPullOrderUpsert = "selly.pull.order.upsert"
|
||||||
SubjectRequestOrderSearch = "elasticsearch/selly.request.order.search"
|
SubjectRequestOrderSearch = "selly.request.order.search"
|
||||||
|
|
||||||
SubjectRequestUserUpsert = "elasticsearch/selly.request.order.upsert"
|
SubjectRequestUserUpsert = "selly.request.user.upsert"
|
||||||
SubjectPullUserUpsert = "elasticsearch/selly.pull.order.upsert"
|
SubjectPullUserUpsert = "selly.pull.user.upsert"
|
||||||
SubjectRequestUserSearch = "elasticsearch/selly.request.user.search"
|
SubjectRequestUserSearch = "selly.request.user.search"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
12
pull.go
12
pull.go
|
@ -5,16 +5,16 @@ type Pull struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProductUpsert ...
|
// ProductUpsert ...
|
||||||
func (Pull) ProductUpsert(query UpdateDataPayload) (bool, error) {
|
func (Pull) ProductUpsert(payload Payload) (bool, error) {
|
||||||
return publishWithJetStream(JetStreamSearchService, SubjectPullProductUpsert, toBytes(query))
|
return publishWithJetStream(JetStreamSearchService, SubjectPullProductUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserUpsert ...
|
// UserUpsert ...
|
||||||
func (Pull) UserUpsert(query UpdateDataPayload) (bool, error) {
|
func (Pull) UserUpsert(payload Payload) (bool, error) {
|
||||||
return publishWithJetStream(JetStreamSearchService, SubjectPullUserUpsert, toBytes(query))
|
return publishWithJetStream(JetStreamSearchService, SubjectPullUserUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderUpsert ...
|
// OrderUpsert ...
|
||||||
func (Pull) OrderUpsert(query UpdateDataPayload) (bool, error) {
|
func (Pull) OrderUpsert(payload Payload) (bool, error) {
|
||||||
return publishWithJetStream(JetStreamSearchService, SubjectPullOrderUpsert, toBytes(query))
|
return publishWithJetStream(JetStreamSearchService, SubjectPullOrderUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
12
request.go
12
request.go
|
@ -10,8 +10,8 @@ func (Request) ProductSearch(query ESQuery) (*Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProductUpsert ...
|
// ProductUpsert ...
|
||||||
func (Request) ProductUpsert(query UpdateDataPayload) (*Response, error) {
|
func (Request) ProductUpsert(payload Payload) (*Response, error) {
|
||||||
return requestNats(SubjectRequestProductUpsert, toBytes(query))
|
return requestNats(SubjectRequestProductUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserSearch ...
|
// UserSearch ...
|
||||||
|
@ -20,8 +20,8 @@ func (Request) UserSearch(query ESQuery) (*Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserUpsert ...
|
// UserUpsert ...
|
||||||
func (Request) UserUpsert(query UpdateDataPayload) (*Response, error) {
|
func (Request) UserUpsert(payload Payload) (*Response, error) {
|
||||||
return requestNats(SubjectRequestUserUpsert, toBytes(query))
|
return requestNats(SubjectRequestUserUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderSearch ...
|
// OrderSearch ...
|
||||||
|
@ -30,6 +30,6 @@ func (Request) OrderSearch(query ESQuery) (*Response, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderUpsert ...
|
// OrderUpsert ...
|
||||||
func (Request) OrderUpsert(query UpdateDataPayload) (*Response, error) {
|
func (Request) OrderUpsert(payload Payload) (*Response, error) {
|
||||||
return requestNats(SubjectRequestOrderUpsert, toBytes(query))
|
return requestNats(SubjectRequestOrderUpsert, toBytes(payload))
|
||||||
}
|
}
|
||||||
|
|
13
struct.go
13
struct.go
|
@ -19,20 +19,13 @@ type Response struct {
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SyncData
|
// Payload ...
|
||||||
// Payload for sync data to service es
|
// payload for sync data to service es
|
||||||
type SyncData struct {
|
type Payload struct {
|
||||||
Index string
|
Index string
|
||||||
Data []byte
|
Data []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdateDataPayload
|
|
||||||
// Payload for insert or update document
|
|
||||||
type UpdateDataPayload struct {
|
|
||||||
Index string
|
|
||||||
Body []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// DeleteDataPayload
|
// DeleteDataPayload
|
||||||
// Payload for delete document
|
// Payload for delete document
|
||||||
type DeleteDataPayload struct {
|
type DeleteDataPayload struct {
|
||||||
|
|
Loading…
Reference in New Issue