@@ -180,18 +180,9 @@ export interface RestateBaseContext {
180
180
// ----------------------------------------------------------------------------
181
181
182
182
/**
183
- * The context that gives access to all Restate-backed operations, for example
184
- * - sending reliable messages / rpc through Restate
185
- * - access/update state (for keyed services)
186
- * - side effects
187
- * - sleeps and delayed calls
188
- * - awakeables
189
- * - ...
190
- *
191
- * This context is for use in **gRPC service** implementations.
192
- * For the rpc-handler API, use the {@link RpcContext} instead.
183
+ * Interface to interact with **gRPC** based services.
193
184
*/
194
- export interface RestateGrpcContext extends RestateBaseContext {
185
+ export interface RestateGrpcChannel {
195
186
/**
196
187
* Unidirectional call to other Restate services ( = in background / async / not waiting on response).
197
188
* To do this, wrap the call via the proto-ts client with oneWayCall, as shown in the example.
@@ -256,6 +247,27 @@ export interface RestateGrpcContext extends RestateBaseContext {
256
247
) : Promise < Uint8Array > ;
257
248
}
258
249
250
+ /**
251
+ * The context that gives access to all Restate-backed operations, for example
252
+ * - sending reliable messages / rpc through Restate
253
+ * - access/update state (for keyed services)
254
+ * - side effects
255
+ * - sleeps and delayed calls
256
+ * - awakeables
257
+ * - ...
258
+ *
259
+ * This context is for use in **gRPC service** implementations.
260
+ * For the rpc-handler API, use the {@link RpcContext} instead.
261
+ */
262
+ export interface RestateGrpcContext
263
+ extends RestateBaseContext ,
264
+ RestateGrpcChannel {
265
+ /**
266
+ * Get the {@link RpcGateway} to invoke Handler-API based services.
267
+ */
268
+ rpcGateway ( ) : RpcGateway ;
269
+ }
270
+
259
271
/**
260
272
* For compatibility, we make the support 'RestateContext' as the type for the Grpc-based API context.
261
273
*/
@@ -323,18 +335,9 @@ export type ServiceApi<_M = unknown> = {
323
335
} ;
324
336
325
337
/**
326
- * The context that gives access to all Restate-backed operations, for example
327
- * - sending reliable messages / RPC through Restate
328
- * - access/update state (for keyed services)
329
- * - side effects
330
- * - sleeps and delayed calls
331
- * - awakeables
332
- * - ...
333
- *
334
- * This context is for use with the **rpc-handler API**.
335
- * For gRPC-based API, use the {@link RestateContext} instead.
338
+ * Interface to interact with **rpc-handler API** based services.
336
339
*/
337
- export interface RpcContext extends RestateBaseContext {
340
+ export interface RpcGateway {
338
341
/**
339
342
* Makes a type-safe request/response RPC to the specified target service.
340
343
*
@@ -463,3 +466,22 @@ export interface RpcContext extends RestateBaseContext {
463
466
*/
464
467
sendDelayed < M > ( opts : ServiceApi < M > , delay : number ) : SendClient < M > ;
465
468
}
469
+
470
+ /**
471
+ * The context that gives access to all Restate-backed operations, for example
472
+ * - sending reliable messages / RPC through Restate
473
+ * - access/update state (for keyed services)
474
+ * - side effects
475
+ * - sleeps and delayed calls
476
+ * - awakeables
477
+ * - ...
478
+ *
479
+ * This context is for use with the **rpc-handler API**.
480
+ * For gRPC-based API, use the {@link RestateContext} instead.
481
+ */
482
+ export interface RpcContext extends RestateBaseContext , RpcGateway {
483
+ /**
484
+ * Get the {@link RestateGrpcChannel} to invoke gRPC based services.
485
+ */
486
+ grpcChannel ( ) : RestateGrpcChannel ;
487
+ }
0 commit comments