starpc 0.10.9 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/echo/echo.pb.d.ts +5 -5
- package/dist/echo/echo.pb.js +20 -20
- package/dist/rpcstream/rpcstream.pb.d.ts +7 -7
- package/dist/rpcstream/rpcstream.pb.js +64 -39
- package/dist/srpc/handler.d.ts +1 -1
- package/dist/srpc/handler.js +6 -2
- package/dist/srpc/rpcproto.pb.d.ts +6 -6
- package/dist/srpc/rpcproto.pb.js +75 -38
- package/echo/echo.pb.ts +144 -88
- package/echo/echo_srpc.pb.go +17 -10
- package/package.json +1 -1
- package/srpc/conn.ts +3 -1
- package/srpc/definition.ts +1 -0
- package/srpc/handler.ts +11 -2
- package/srpc/rpcproto.pb.ts +273 -183
- package/srpc/server.ts +1 -3
package/srpc/handler.ts
CHANGED
|
@@ -145,7 +145,16 @@ export function createInvokeFn<R, O>(
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
// createHandler creates a handler from a definition and an implementation.
|
|
148
|
-
|
|
148
|
+
// if serviceID is not set, uses the fullName of the service as the identifier.
|
|
149
|
+
export function createHandler(
|
|
150
|
+
definition: Definition,
|
|
151
|
+
impl: any,
|
|
152
|
+
serviceID?: string
|
|
153
|
+
): Handler {
|
|
154
|
+
// serviceID defaults to the full name of the service from Protobuf.
|
|
155
|
+
serviceID = serviceID || definition.fullName
|
|
156
|
+
|
|
157
|
+
// build map of method ID -> method prototype.
|
|
149
158
|
const methodMap: MethodMap = {}
|
|
150
159
|
for (const methodInfo of Object.values(definition.methods)) {
|
|
151
160
|
const methodName = methodInfo.name
|
|
@@ -157,5 +166,5 @@ export function createHandler(definition: Definition, impl: any): Handler {
|
|
|
157
166
|
methodMap[methodName] = createInvokeFn(methodInfo, methodProto)
|
|
158
167
|
}
|
|
159
168
|
|
|
160
|
-
return new StaticHandler(
|
|
169
|
+
return new StaticHandler(serviceID, methodMap)
|
|
161
170
|
}
|