Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify example pubsub #558

Merged
merged 6 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion examples/pubsub/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ By default, the example uses HTTP. To use gRPC instead:
daprPort: process.env.DAPR_GRPC_PORT,
},
});
const client = new DaprClient(daprHost, process.env.DAPR_GRPC_PORT, CommunicationProtocolEnum.GRPC);

const client = new DaprClient({
daprHost,
daprPort: process.env.DAPR_GRPC_PORT,
communicationProtocol: CommunicationProtocolEnum.GRPC,
});
```

- To run:
Expand Down
10 changes: 5 additions & 5 deletions examples/pubsub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ async function start() {
});

// Publish multiple messages to a topic with default config.
await server.pubsub.subscribeBulk("my-pubsub-component", "my-topic", async (data: Record<string, any>) => {
await server.pubsub.subscribeBulk("my-pubsub-component", "my-topic-bulk", async (data: Record<string, any>) => {
// The library parses JSON when possible.
console.log(`[Dapr-JS][Example] Received on subscription: ${JSON.stringify(data)}`);
});

// Publish multiple messages to a topic with specific maxMessagesCount and maxAwaitDurationMs.
await server.pubsub.subscribeBulk(
"my-pubsub-component",
"my-topic",
"my-topic-bulk-with-config",
async (data: Record<string, any>) => {
// The library parses JSON when possible.
console.log(`[Dapr-JS][Example] Received on subscription: ${JSON.stringify(data)}`);
Expand Down Expand Up @@ -85,12 +85,12 @@ async function start() {

console.log("[Dapr-JS][Example] Bulk publishing multiple plain messages");
const messages = ["message 1", "message 2", "message 3"];
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic", messages);
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic-bulk", messages);
console.log(`[Dapr-JS][Example] Bulk publish response: ${JSON.stringify(response)}`);

console.log("[Dapr-JS][Example] Bulk publishing multiple JSON messages");
const jsonMessages = [{ hello: "message 1" }, { hello: "message 2" }, { hello: "message 3" }];
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic", jsonMessages);
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic-bulk", jsonMessages);
console.log(`[Dapr-JS][Example] Bulk publish response: ${JSON.stringify(response)}`);

console.log("[Dapr-JS][Example] Bulk publishing with entryID and custom content type");
Expand All @@ -111,7 +111,7 @@ async function start() {
event: "foo message 3",
},
];
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic", bulkPublishMessages);
response = await client.pubsub.publishBulk("my-pubsub-component", "my-topic-bulk-with-config", bulkPublishMessages);
console.log(`[Dapr-JS][Example] Bulk publish response: ${JSON.stringify(response)}`);
}

Expand Down
Loading