mirror of https://github.com/dapr/quickstarts.git
Removed unwanted code
This commit is contained in:
parent
ed20d72e41
commit
8c88f1f668
|
|
@ -10,6 +10,8 @@ start().catch((e) => {
|
|||
});
|
||||
|
||||
async function start(orderId) {
|
||||
const PUBSUB_NAME = "order_pub_sub"
|
||||
const TOPIC_NAME = "orders"
|
||||
const server = new DaprServer(
|
||||
serverHost,
|
||||
serverPort,
|
||||
|
|
@ -17,7 +19,7 @@ async function start(orderId) {
|
|||
process.env.DAPR_HTTP_PORT,
|
||||
CommunicationProtocolEnum.HTTP
|
||||
);
|
||||
await server.pubsub.subscribe("order_pub_sub", "orders", async (orderId) => {
|
||||
await server.pubsub.subscribe(PUBSUB_NAME, TOPIC_NAME, async (orderId) => {
|
||||
console.log(`Subscriber received: ${JSON.stringify(orderId)}`)
|
||||
});
|
||||
await server.startServer();
|
||||
|
|
|
|||
|
|
@ -24,4 +24,4 @@ func main() {
|
|||
r := mux.NewRouter()
|
||||
r.HandleFunc("/checkout/{orderId}", getCheckout).Methods("GET")
|
||||
http.ListenAndServe(":6002", r)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,17 +4,12 @@ import (
|
|||
"context"
|
||||
"log"
|
||||
"math/rand"
|
||||
"time"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
dapr "github.com/dapr/go-sdk/client"
|
||||
|
||||
)
|
||||
|
||||
type Order struct {
|
||||
orderName string
|
||||
orderNum string
|
||||
}
|
||||
|
||||
func main() {
|
||||
for i := 0; i < 10; i++ {
|
||||
time.Sleep(5000)
|
||||
|
|
@ -34,7 +29,7 @@ func main() {
|
|||
if err := client.SaveState(ctx, STATE_STORE_NAME, "order_2", []byte(strconv.Itoa(orderId))); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
result, err := client.GetState(ctx, STATE_STORE_NAME, "order_2")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
|
|
@ -52,4 +47,3 @@ func main() {
|
|||
log.Println(result)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue