Internal Use of PCS Pub/Sub service.
Only for PCS Applications.
Use go get
to install the package:
go get github.com/PCS-Indonesia/pcspubsub/pubsubclient
{
"command" : "insert|update|delete|notify",
"payload" : <content>,
"id" : <id>,
"detail" : <additional data>
}
package main
import (
"github.com/PCS-Indonesia/pcspubsub/pubsubclient"
)
func main() {
pubsubclient.NewPubSubClient("project-id","your-credentials.json")
pubsubclient.ReceiveMessages("subscription-name", func() {
// Do something
})
}
package main
import (
"github.com/PCS-Indonesia/pcspubsub/pubsubclient"
)
func main() {
pubsubclient.NewPubSubClient("project-id","your-credentials.json")
var message pubsubclient.CommandMessage
message.Command = "command"
message.Payload = "your json body"
message.ID = "id"
message.Deatail = "detail"
err := pubsubclient.PublishMessage("topic-name", message)
if err != nil {
// Error Handling
}
}
- Copy credential file to root directory
- Copy
.env.example
as.env
and fill it - Run pub with
go run sample.go pub
- Run sub with
go run sample.go sub