Method names for a service definition.
The type of a request for the given method of a service.
The type of a response for the given method of a service.
All service definitions derive from this type.
It associates a method name with request and response types as follows:
const bankingServiceDefinition = {
getBalance: {
request: {} as {
userId: string;
},
response: {} as {
value: number;
unit: string;
},
},
transfer: {
request: {} as {
fromUserId: string;
toUserId: string;
amount: {
value: number;
unit: string;
}
},
response: {} as {},
},
};
The {} as
allows us to derive proper typing. It is better than defining
a service with, e.g., an interface: with the definition above, the methods
can be enumerated.
Method names of the unary methods in a service definition (the server streams are filtered out).
The type of service methods.
A single request is followed by multiple responses (they can be sent at different points in time).
Server streams can be used, e.g., by a web application to subscribe to push notifications.
A single request is followed by a single response. Unary RPCs are the most common ones.
Definitions common to both the client and server sides of RPC services.
Copyright (c) Aiden.ai
This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.