Skip to content

Commit f28d20b

Browse files
authored
Merge pull request #142 from nitrictech/release/v0.8.0
Release v0.8.0
2 parents c59bcf4 + 9fb227c commit f28d20b

File tree

6 files changed

+30
-91
lines changed

6 files changed

+30
-91
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/enhancement.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<a href="https://npmjs.org/package/@nitric/sdk">
2020
<img alt="Downloads/week" src="https://img.shields.io/npm/dw/@nitric/sdk.svg">
2121
</a>
22+
<a href="https://discord.gg/Webemece5C"><img alt="Discord" src="https://img.shields.io/discord/955259353043173427?label=discord"></a>
2223
</p>
2324

2425
The NodeJS SDK supports the use of the Nitric framework with NodeJS 12+. For more information, check out the main [Nitric repo](https://github.com/nitrictech/nitric).
@@ -35,6 +36,8 @@ The SDK is in early stage development and APIs and interfaces are still subject
3536

3637
- Ask questions in [GitHub discussions](https://github.com/nitrictech/nitric/discussions)
3738

39+
- Join us on [Discord](https://discord.gg/Webemece5C)
40+
3841
- Find us on [Twitter](https://twitter.com/nitric_io)
3942

4043
- Send us an [email](mailto:maintainers@nitric.io)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
],
2828
"dependencies": {
2929
"@grpc/grpc-js": "^1.5.9",
30-
"@nitric/api": "v0.17.0",
30+
"@nitric/api": "v0.19.0",
3131
"google-protobuf": "3.14.0",
3232
"tslib": "^2.1.0"
3333
},

src/api/events/v0/events.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ function newEventServiceClients(): {
3636
};
3737
}
3838

39+
export interface PublishOptions {
40+
/** Number of seconds to delay message publishing by */
41+
delay?: number;
42+
}
43+
44+
const DEFAULT_PUBLISH_OPTS: PublishOptions = {
45+
delay: 0
46+
};
47+
3948
export class Topic {
4049
eventing: Eventing;
4150
name: string;
@@ -48,6 +57,7 @@ export class Topic {
4857
/**
4958
* Publishes an event to a nitric topic
5059
* @param event The event to publish
60+
* @param opts Additional publishing options
5161
* @returns NitricEvent containing the unique id of the event (if not provided it will be generated)
5262
*
5363
* @example
@@ -64,22 +74,30 @@ export class Topic {
6474
* value: "Hello World!"
6575
* }
6676
* };
67-
*
68-
* return await topic.publish(event);
77+
* // Publish immediately
78+
* await topic.publish(event);
79+
*
80+
* // Publish after 10 seconds delay
81+
* await topic.publish(event, { delay: 10 });
6982
* }
7083
* ```
7184
*/
72-
async publish(event: NitricEvent): Promise<NitricEvent> {
85+
async publish(event: NitricEvent, opts: PublishOptions = DEFAULT_PUBLISH_OPTS): Promise<NitricEvent> {
7386
const { id, payloadType = 'none', payload } = event;
87+
const publishOpts = {
88+
...DEFAULT_PUBLISH_OPTS,
89+
...opts,
90+
};
7491
const request = new EventPublishRequest();
7592
const evt = new PbEvent();
7693

7794
evt.setId(id);
7895
evt.setPayload(Struct.fromJavaScript(payload));
7996
evt.setPayloadType(payloadType);
80-
97+
8198
request.setTopic(this.name);
8299
request.setEvent(evt);
100+
request.setDelay(publishOpts.delay);
83101

84102
return new Promise<NitricEvent>((resolve, reject) => {
85103
this.eventing.EventServiceClient.publish(request, (error, response) => {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,10 @@
531531
"@types/yargs" "^15.0.0"
532532
chalk "^4.0.0"
533533

534-
"@nitric/api@v0.17.0":
535-
version "0.17.0"
536-
resolved "https://registry.yarnpkg.com/@nitric/api/-/api-0.17.0.tgz#e4ad7b06d9bf65013d9237a77212d2742217c69e"
537-
integrity sha512-va0bGIb7ns2eALBShNuO0E5VH2KQqMU8+HWrBSSdIarMYy6hiFJZojttQd5MYFquMcY/FE6OEvpZRvzxBm/M0g==
534+
"@nitric/api@v0.19.0":
535+
version "0.19.0"
536+
resolved "https://registry.yarnpkg.com/@nitric/api/-/api-0.19.0.tgz#4af4ee64dbc2588b5769936fff07b9fb8acd3fae"
537+
integrity sha512-J2++9PQX2c6yhWOOiFL/X5X6FHMZsF3ieQ7Vioky5Uwdd9HSjytcuPtiAjx158iwSZz8w9Kai5c4jsFN/WF+aw==
538538
dependencies:
539539
google-protobuf "3.14.0"
540540
tslib "^2.1.0"

0 commit comments

Comments
 (0)