Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func main() {

// initiate consumer
consumer, err := messaging.NewConsumer(messaging.ConsumerConfig{
Topic: "test", // Change the topic
Channel: "test", // Change the channel
Topic: "papapan", // Change the topic
Channel: "papapan", // Change the channel
LookupAddress: "172.18.59.254:4161",
MaxAttempts: defaultConsumerMaxAttempts,
MaxInFlight: defaultConsumerMaxInFlight,
Expand All @@ -67,19 +67,43 @@ func main() {
http.HandleFunc("/publish_payment", handlePublish)

go messaging.RunConsumer(consumer)
log.Fatal(http.ListenAndServe(":8090", nil))
log.Fatal(http.ListenAndServe(":8095", nil))
}

func handlePublish(w http.ResponseWriter, r *http.Request) {
// Do Publish
topic := "" // TODO: update to given topic name
msg := "" // TODO: write your message here

// Pseudo code gak ngerti NSQ

/*
Disini kita encrypt data si User + Item + Payment sebelum kirim
1.
type Param struct {
UserParam User
ItemParam Item
PaymentParam Payment
}
2. encrypt(param)
3. Bawa ke publisher encryptednya biar di tengah jalan aman2 saja
*/

// Gk ngerti NSQ
topic := "papapan" // TODO: update to given topic name
msg := "tes" // TODO: write your message here
producer.Publish(topic, msg)
}

func handleMessage(message *nsq.Message) error {
// Handle message NSQ here

// Pseudo code gak ngerti NSQ

/*
Dia disini kan dah dapet data yang di encrypt dari si publisher
1. Decrypt kembali datanya si User, Item, Payment
2. Lalu olah datanya disini
*/

message.Finish()
return nil
}