go-sdk/examples/pubsub
mikeee e45054d1f6
introduces go1.22 to tests (and misc cleanup) (#504)
* introduces go1.22

- dapr-bot updated to use go1.22
- adds go1.22 to the test jobs
- adds go1.22 to tooling tests

Signed-off-by: mikeee <hey@mike.ee>

* remove 1.20 tests

Signed-off-by: mikeee <hey@mike.ee>

* dapr-bot workflow changes

- retrieve go version from go.mod
- run go mod tidy rather than go get

Signed-off-by: mikeee <hey@mike.ee>

* bump action versions and release go version is now from go.mod

Signed-off-by: mikeee <hey@mike.ee>

* bump main and tool mod files to 1.21

Signed-off-by: mikeee <hey@mike.ee>

* fix dapr-bot test

Signed-off-by: mikeee <hey@mike.ee>

* test dapr-bot using go version from go.mod

Signed-off-by: mikeee <hey@mike.ee>

* bump action versions and remove explicit caching

Signed-off-by: mikeee <hey@mike.ee>

* bump examples to go1.21 and bump deps

Signed-off-by: mikeee <hey@mike.ee>

* bump compatibility check to 1.21 in the make flow

Signed-off-by: mikeee <hey@mike.ee>

* bump to dapr1.13rc2

Signed-off-by: mikeee <hey@mike.ee>

* tidy sums

Signed-off-by: mikeee <hey@mike.ee>

* empty commit to trigger tests (flaky example service validation)

Signed-off-by: mikeee <hey@mike.ee>

* remove conditionals for modtidy/checkdiff runs

Signed-off-by: mikeee <hey@mike.ee>

---------

Signed-off-by: mikeee <hey@mike.ee>
2024-02-08 10:08:28 -08:00
..
config minor reorg of 'examples' folder (#178) 2021-06-24 09:51:01 -07:00
pub Add support for bulk publish (#384) 2023-03-31 14:57:57 +08:00
sub Add support for bulk publish (#384) 2023-03-31 14:57:57 +08:00
README.md Update protos and client's configuration methods with stable config api (#391) 2023-05-17 22:40:52 -07:00
go.mod introduces go1.22 to tests (and misc cleanup) (#504) 2024-02-08 10:08:28 -08:00
go.sum introduces go1.22 to tests (and misc cleanup) (#504) 2024-02-08 10:08:28 -08:00

README.md

Dapr PubSub Example with go-sdk

This folder contains two Go files that use the Go SDK to invoke the Dapr Pub/Sub API.

Diagram

Step

Prepare

  • Dapr installed

Run Subscriber Server

dapr run --app-id sub \
         --app-protocol http \
         --app-port 8080 \
         --dapr-http-port 3500 \
         --log-level debug \
         --resources-path ./config \
         go run sub/sub.go

Run Publisher

export DAPR_PUBSUB_NAME=messages

dapr run --app-id pub \
         --log-level debug \
         --resources-path ./config \
         go run pub/pub.go

Cleanup

dapr stop --app-id sub
(lsof -i:8080 | grep sub) | awk '{print $2}' | xargs  kill

Result

== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: neworder, ID: 82427280-1c18-4fab-b901-c7e68d295d31, Data: ping
== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: neworder, ID: cc13829c-af77-4303-a4d7-55cdc0b0fa7d, Data: multi-pong
== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: neworder, ID: 0147f10a-d6c3-4b16-ad5a-6776956757dd, Data: multi-ping