Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

Commit a71eeeb

Browse files
authored
Merge branch 'master' into autosynth-self
2 parents d449b14 + 77be4b3 commit a71eeeb

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

samples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"test": "mocha system-test --timeout 600000"
1515
},
1616
"dependencies": {
17+
"@google-cloud/pubsub": "^2.10.0",
1718
"@opentelemetry/api": "^0.11.0",
18-
"@opentelemetry/tracing": "^0.11.0",
19-
"@google-cloud/pubsub": "^2.10.0"
19+
"@opentelemetry/tracing": "^0.11.0"
2020
},
2121
"devDependencies": {
2222
"chai": "^4.2.0",

src/subscription.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,32 @@ export type SetSubscriptionMetadataResponse = MetadataResponse;
8888
export type DetachSubscriptionCallback = EmptyCallback;
8989
export type DetachSubscriptionResponse = EmptyResponse;
9090

91+
// JSDoc won't see these, so this is just to let you get typings
92+
// in your editor of choice.
93+
//
94+
// NOTE: These are commented out for now because we don't want to
95+
// break any existing clients that rely on not-entirely-correct
96+
// typings. We'll re-enable on the next major.
97+
/* export declare interface Subscription {
98+
on(
99+
event: 'message',
100+
listener: (message: Message) => void
101+
): this;
102+
on(
103+
event: 'error',
104+
listener: (error: StatusError) => void
105+
): this;
106+
on(event: 'close', listener: () => void): this;
107+
108+
// Only used internally.
109+
on(event: 'newListener', listener: Function): this;
110+
on(event: 'removeListener', listener: Function): this;
111+
112+
// Catch-all. If you get an error about this line, it means you're
113+
// using an unsupported event type or listener type.
114+
on(event: string, listener: void): this;
115+
} */
116+
91117
/**
92118
* @typedef {object} ExpirationPolicy
93119
* A policy that specifies the conditions for this subscription's expiration. A
@@ -120,7 +146,16 @@ export type DetachSubscriptionResponse = EmptyResponse;
120146
* All Subscription objects are instances of an
121147
* [EventEmitter](http://nodejs.org/api/events.html). The subscription will pull
122148
* for messages automatically as long as there is at least one listener assigned
123-
* for the `message` event.
149+
* for the `message` event. Available events:
150+
*
151+
* Upon receipt of a message:
152+
* on(event: 'message', listener: (message: {@link Message}) => void): this;
153+
*
154+
* Upon receipt of an error:
155+
* on(event: 'error', listener: (error: Error) => void): this;
156+
*
157+
* Upon the closing of the subscriber:
158+
* on(event: 'close', listener: Function): this;
124159
*
125160
* By default Subscription objects allow you to process 100 messages at the same
126161
* time. You can fine tune this value by adjusting the

system-test/pubsub.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,12 +904,12 @@ describe('pubsub', () => {
904904

905905
// This creates a Promise that hooks the 'message' callback of the
906906
// subscription above, and resolves when that callback calls `resolve`.
907-
type WorkCallback<T> = (arg: T, resolve: Function) => void;
907+
type WorkCallback = (arg: Message, resolve: Function) => void;
908908
function makeMessagePromise<T>(
909-
workCallback: WorkCallback<T>
909+
workCallback: WorkCallback
910910
): Promise<void> {
911911
return new Promise(resolve => {
912-
subscription.on('message', (arg: T) => {
912+
subscription.on('message', (arg: Message) => {
913913
workCallback(arg, resolve);
914914
});
915915
});

0 commit comments

Comments
 (0)