mirror of https://github.com/dapr/go-sdk.git
34 lines
532 B
Go
34 lines
532 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"os"
|
|
|
|
dapr "github.com/dapr/go-sdk/client"
|
|
)
|
|
|
|
var (
|
|
// set the environment as instructions.
|
|
pubsubName = os.Getenv("DAPR_PUBSUB_NAME")
|
|
topicName = "neworder"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.Background()
|
|
data := []byte("ping")
|
|
|
|
client, err := dapr.NewClient()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
defer client.Close()
|
|
|
|
if err := client.PublishEvent(ctx, pubsubName, topicName, data); err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println("data published")
|
|
|
|
fmt.Println("Done (CTRL+C to Exit)")
|
|
}
|