Skip to content

Commit 3a6a3cd

Browse files
docs: add unwrap and on methods to custom transporter class
1 parent 14e4191 commit 3a6a3cd

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

content/microservices/custom-transport.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,37 @@ import { CustomTransportStrategy, Server } from '@nestjs/microservices';
1919

2020
class GoogleCloudPubSubServer
2121
extends Server
22-
implements CustomTransportStrategy {
22+
implements CustomTransportStrategy
23+
{
2324
/**
24-
* This method is triggered when you run "app.listen()".
25+
* Triggered when you run "app.listen()".
2526
*/
2627
listen(callback: () => void) {
2728
callback();
2829
}
2930

3031
/**
31-
* This method is triggered on application shutdown.
32+
* Triggered on application shutdown.
3233
*/
3334
close() {}
35+
36+
/**
37+
* You can ignore this method if you don't want transporter users
38+
* to be able to register event listeners. Most custom implementations
39+
* will not need this.
40+
*/
41+
on(event: string, callback: Function) {
42+
throw new Error('Method not implemented.');
43+
}
44+
45+
/**
46+
* You can ignore this method if you don't want transporter users
47+
* to be able to retrieve the underlying native server. Most custom implementations
48+
* will not need this.
49+
*/
50+
unwrap<T = never>(): T {
51+
throw new Error('Method not implemented.');
52+
}
3453
}
3554
```
3655

@@ -137,6 +156,9 @@ class GoogleCloudPubSubClient extends ClientProxy {
137156
packet: ReadPacket<any>,
138157
callback: (packet: WritePacket<any>) => void,
139158
): Function {}
159+
unwrap<T = never>(): T {
160+
throw new Error('Method not implemented.');
161+
}
140162
}
141163
```
142164

@@ -174,6 +196,10 @@ class GoogleCloudPubSubClient extends ClientProxy {
174196

175197
return () => console.log('teardown');
176198
}
199+
200+
unwrap<T = never>(): T {
201+
throw new Error('Method not implemented.');
202+
}
177203
}
178204
```
179205

0 commit comments

Comments
 (0)