Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement RFC-7 #114

Merged
merged 23 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"${workspaceRoot}/node_modules/.bin/jest",
"--runInBand",
"--coverage",
"test/push-channel.spec.ts"
"test/codegen-server.spec.ts"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
9 changes: 6 additions & 3 deletions etc/rpc.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ export type AsyncProcedureResultClient = Promise<Uint8Array | AsyncGenerator<Uin
export type AsyncProcedureResultServer = Promise<Uint8Array | void> | AsyncGenerator<Uint8Array>;

// @public (undocumented)
export type CallableProcedureClient = (payload: Uint8Array) => AsyncProcedureResultClient;
export type CallableProcedureClient = (payload: Uint8Array | AsyncIterable<Uint8Array>) => AsyncProcedureResultClient;

// @public (undocumented)
export type CallableProcedureServer<Context> = (payload: Uint8Array, context: Context) => AsyncProcedureResultServer;
export type CallableProcedureServer<Context> = (payload: Uint8Array | AsyncIterable<Uint8Array>, context: Context) => AsyncProcedureResultServer;

// @public (undocumented)
export type ClientModuleDefinition = Record<string, CallableProcedureClient>;
Expand Down Expand Up @@ -88,7 +88,7 @@ export type RpcServerPort<Context> = Pick<Emitter<RpcPortEvents>, "on" | "emit">
readonly portName: string;
registerModule(moduleName: string, moduleDefinition: ModuleGeneratorFunction<Context>): void;
loadModule(moduleName: string): Promise<ServerModuleDeclaration<any>>;
callProcedure(procedureId: number, argument: Uint8Array, context: Context): AsyncProcedureResultServer;
callProcedure(procedureId: number, argument: Uint8Array | AsyncIterable<Uint8Array>, context: Context): AsyncProcedureResultServer;
close(): void;
};

Expand All @@ -113,6 +113,9 @@ export type ServerModuleProcedure<Context> = {
callable: CallableProcedureServer<Context>;
};

// @public (undocumented)
export function streamWithoutAck<T extends object>(args: T): T;

// @public (undocumented)
export type Transport = Pick<Emitter<TransportEvents>, "on" | "emit"> & {
sendMessage(message: Uint8Array): void;
Expand Down
2 changes: 2 additions & 0 deletions example/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ message QueryBooksRequest {
service BookService {
rpc GetBook(GetBookRequest) returns (Book) {}
rpc QueryBooks(QueryBooksRequest) returns (stream Book) {}
rpc GetBookStream(stream GetBookRequest) returns (Book) {}
rpc QueryBooksStream(stream GetBookRequest) returns (stream Book) {}
}
Loading