Skip to content

Commit 56151d1

Browse files
committed
feat: add common HandleStreamFunc
Signed-off-by: Christian Stewart <[email protected]>
1 parent d074965 commit 56151d1

File tree

10 files changed

+288
-282
lines changed

10 files changed

+288
-282
lines changed

echo/echo.pb.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
33
/* eslint-disable */
44

5-
import type { MessageType, PartialFieldInfo } from "@aptre/protobuf-es-lite";
6-
import { createMessageType, ScalarType } from "@aptre/protobuf-es-lite";
5+
import type { MessageType, PartialFieldInfo } from '@aptre/protobuf-es-lite'
6+
import { createMessageType, ScalarType } from '@aptre/protobuf-es-lite'
77

8-
export const protobufPackage = "echo";
8+
export const protobufPackage = 'echo'
99

1010
/**
1111
* EchoMsg is the message body for Echo.
@@ -16,16 +16,14 @@ export interface EchoMsg {
1616
/**
1717
* @generated from field: string body = 1;
1818
*/
19-
body?: string;
20-
21-
};
19+
body?: string
20+
}
2221

2322
// EchoMsg contains the message type declaration for EchoMsg.
2423
export const EchoMsg: MessageType<EchoMsg> = createMessageType({
25-
typeName: "echo.EchoMsg",
26-
fields: [
27-
{ no: 1, name: "body", kind: "scalar", T: ScalarType.STRING },
28-
] as readonly PartialFieldInfo[],
29-
packedByDefault: true,
30-
});
31-
24+
typeName: 'echo.EchoMsg',
25+
fields: [
26+
{ no: 1, name: 'body', kind: 'scalar', T: ScalarType.STRING },
27+
] as readonly PartialFieldInfo[],
28+
packedByDefault: true,
29+
})

echo/echo_srpc.pb.ts

Lines changed: 46 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,31 @@
22
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
33
/* eslint-disable */
44

5-
import { EchoMsg } from "./echo.pb.js";
6-
import { Empty, MethodKind } from "@aptre/protobuf-es-lite";
7-
import { RpcStreamPacket } from "../rpcstream/rpcstream.pb.js";
8-
import { buildDecodeMessageTransform, buildEncodeMessageTransform, MessageStream, ProtoRpc } from "starpc";
5+
import { EchoMsg } from './echo.pb.js'
6+
import { Empty, MethodKind } from '@aptre/protobuf-es-lite'
7+
import { RpcStreamPacket } from '../rpcstream/rpcstream.pb.js'
8+
import {
9+
buildDecodeMessageTransform,
10+
buildEncodeMessageTransform,
11+
MessageStream,
12+
ProtoRpc,
13+
} from 'starpc'
914

1015
/**
1116
* Echoer service returns the given message.
1217
*
1318
* @generated from service echo.Echoer
1419
*/
1520
export const EchoerDefinition = {
16-
typeName: "echo.Echoer",
21+
typeName: 'echo.Echoer',
1722
methods: {
1823
/**
1924
* Echo returns the given message.
2025
*
2126
* @generated from rpc echo.Echoer.Echo
2227
*/
2328
Echo: {
24-
name: "Echo",
29+
name: 'Echo',
2530
I: EchoMsg,
2631
O: EchoMsg,
2732
kind: MethodKind.Unary,
@@ -32,7 +37,7 @@ export const EchoerDefinition = {
3237
* @generated from rpc echo.Echoer.EchoServerStream
3338
*/
3439
EchoServerStream: {
35-
name: "EchoServerStream",
40+
name: 'EchoServerStream',
3641
I: EchoMsg,
3742
O: EchoMsg,
3843
kind: MethodKind.ServerStreaming,
@@ -43,7 +48,7 @@ export const EchoerDefinition = {
4348
* @generated from rpc echo.Echoer.EchoClientStream
4449
*/
4550
EchoClientStream: {
46-
name: "EchoClientStream",
51+
name: 'EchoClientStream',
4752
I: EchoMsg,
4853
O: EchoMsg,
4954
kind: MethodKind.ClientStreaming,
@@ -54,7 +59,7 @@ export const EchoerDefinition = {
5459
* @generated from rpc echo.Echoer.EchoBidiStream
5560
*/
5661
EchoBidiStream: {
57-
name: "EchoBidiStream",
62+
name: 'EchoBidiStream',
5863
I: EchoMsg,
5964
O: EchoMsg,
6065
kind: MethodKind.BiDiStreaming,
@@ -65,7 +70,7 @@ export const EchoerDefinition = {
6570
* @generated from rpc echo.Echoer.RpcStream
6671
*/
6772
RpcStream: {
68-
name: "RpcStream",
73+
name: 'RpcStream',
6974
I: RpcStreamPacket,
7075
O: RpcStreamPacket,
7176
kind: MethodKind.BiDiStreaming,
@@ -76,13 +81,13 @@ export const EchoerDefinition = {
7681
* @generated from rpc echo.Echoer.DoNothing
7782
*/
7883
DoNothing: {
79-
name: "DoNothing",
84+
name: 'DoNothing',
8085
I: Empty,
8186
O: Empty,
8287
kind: MethodKind.Unary,
8388
},
84-
}
85-
} as const;
89+
},
90+
} as const
8691

8792
/**
8893
* Echoer service returns the given message.
@@ -95,61 +100,54 @@ export interface Echoer {
95100
*
96101
* @generated from rpc echo.Echoer.Echo
97102
*/
98-
Echo(
99-
request: EchoMsg, abortSignal?: AbortSignal
100-
):
101-
Promise<EchoMsg>
103+
Echo(request: EchoMsg, abortSignal?: AbortSignal): Promise<EchoMsg>
102104

103105
/**
104106
* EchoServerStream is an example of a server -> client one-way stream.
105107
*
106108
* @generated from rpc echo.Echoer.EchoServerStream
107109
*/
108110
EchoServerStream(
109-
request: EchoMsg, abortSignal?: AbortSignal
110-
):
111-
MessageStream<EchoMsg>
111+
request: EchoMsg,
112+
abortSignal?: AbortSignal,
113+
): MessageStream<EchoMsg>
112114

113115
/**
114116
* EchoClientStream is an example of client->server one-way stream.
115117
*
116118
* @generated from rpc echo.Echoer.EchoClientStream
117119
*/
118120
EchoClientStream(
119-
request: MessageStream<EchoMsg>, abortSignal?: AbortSignal
120-
):
121-
Promise<EchoMsg>
121+
request: MessageStream<EchoMsg>,
122+
abortSignal?: AbortSignal,
123+
): Promise<EchoMsg>
122124

123125
/**
124126
* EchoBidiStream is an example of a two-way stream.
125127
*
126128
* @generated from rpc echo.Echoer.EchoBidiStream
127129
*/
128130
EchoBidiStream(
129-
request: MessageStream<EchoMsg>, abortSignal?: AbortSignal
130-
):
131-
MessageStream<EchoMsg>
131+
request: MessageStream<EchoMsg>,
132+
abortSignal?: AbortSignal,
133+
): MessageStream<EchoMsg>
132134

133135
/**
134136
* RpcStream opens a nested rpc call stream.
135137
*
136138
* @generated from rpc echo.Echoer.RpcStream
137139
*/
138140
RpcStream(
139-
request: MessageStream<RpcStreamPacket>, abortSignal?: AbortSignal
140-
):
141-
MessageStream<RpcStreamPacket>
141+
request: MessageStream<RpcStreamPacket>,
142+
abortSignal?: AbortSignal,
143+
): MessageStream<RpcStreamPacket>
142144

143145
/**
144146
* DoNothing does nothing.
145147
*
146148
* @generated from rpc echo.Echoer.DoNothing
147149
*/
148-
DoNothing(
149-
request: Empty, abortSignal?: AbortSignal
150-
):
151-
Promise<Empty>
152-
150+
DoNothing(request: Empty, abortSignal?: AbortSignal): Promise<Empty>
153151
}
154152

155153
export const EchoerServiceName = EchoerDefinition.typeName
@@ -172,10 +170,7 @@ export class EchoerClient implements Echoer {
172170
*
173171
* @generated from rpc echo.Echoer.Echo
174172
*/
175-
async Echo(
176-
request: EchoMsg, abortSignal?: AbortSignal
177-
):
178-
Promise<EchoMsg> {
173+
async Echo(request: EchoMsg, abortSignal?: AbortSignal): Promise<EchoMsg> {
179174
const requestMsg = EchoMsg.create(request)
180175
const result = await this.rpc.request(
181176
this.service,
@@ -192,9 +187,9 @@ Promise<EchoMsg> {
192187
* @generated from rpc echo.Echoer.EchoServerStream
193188
*/
194189
EchoServerStream(
195-
request: EchoMsg, abortSignal?: AbortSignal
196-
):
197-
MessageStream<EchoMsg> {
190+
request: EchoMsg,
191+
abortSignal?: AbortSignal,
192+
): MessageStream<EchoMsg> {
198193
const requestMsg = EchoMsg.create(request)
199194
const result = this.rpc.serverStreamingRequest(
200195
this.service,
@@ -211,9 +206,9 @@ MessageStream<EchoMsg> {
211206
* @generated from rpc echo.Echoer.EchoClientStream
212207
*/
213208
async EchoClientStream(
214-
request: MessageStream<EchoMsg>, abortSignal?: AbortSignal
215-
):
216-
Promise<EchoMsg> {
209+
request: MessageStream<EchoMsg>,
210+
abortSignal?: AbortSignal,
211+
): Promise<EchoMsg> {
217212
const result = await this.rpc.clientStreamingRequest(
218213
this.service,
219214
EchoerDefinition.methods.EchoClientStream.name,
@@ -229,9 +224,9 @@ Promise<EchoMsg> {
229224
* @generated from rpc echo.Echoer.EchoBidiStream
230225
*/
231226
EchoBidiStream(
232-
request: MessageStream<EchoMsg>, abortSignal?: AbortSignal
233-
):
234-
MessageStream<EchoMsg> {
227+
request: MessageStream<EchoMsg>,
228+
abortSignal?: AbortSignal,
229+
): MessageStream<EchoMsg> {
235230
const result = this.rpc.bidirectionalStreamingRequest(
236231
this.service,
237232
EchoerDefinition.methods.EchoBidiStream.name,
@@ -247,9 +242,9 @@ MessageStream<EchoMsg> {
247242
* @generated from rpc echo.Echoer.RpcStream
248243
*/
249244
RpcStream(
250-
request: MessageStream<RpcStreamPacket>, abortSignal?: AbortSignal
251-
):
252-
MessageStream<RpcStreamPacket> {
245+
request: MessageStream<RpcStreamPacket>,
246+
abortSignal?: AbortSignal,
247+
): MessageStream<RpcStreamPacket> {
253248
const result = this.rpc.bidirectionalStreamingRequest(
254249
this.service,
255250
EchoerDefinition.methods.RpcStream.name,
@@ -264,10 +259,7 @@ MessageStream<RpcStreamPacket> {
264259
*
265260
* @generated from rpc echo.Echoer.DoNothing
266261
*/
267-
async DoNothing(
268-
request: Empty, abortSignal?: AbortSignal
269-
):
270-
Promise<Empty> {
262+
async DoNothing(request: Empty, abortSignal?: AbortSignal): Promise<Empty> {
271263
const requestMsg = Empty.create(request)
272264
const result = await this.rpc.request(
273265
this.service,
@@ -277,5 +269,4 @@ Promise<Empty> {
277269
)
278270
return Empty.fromBinary(result)
279271
}
280-
281272
}

0 commit comments

Comments
 (0)