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

ci: merge staging to master #15

Merged
merged 6 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@matrixai/rpc",
"version": "0.1.2",
"version": "0.1.5",
"author": "Matrix AI",
"contributors": [
{
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/ClientHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ abstract class ClientHandler<
Input extends JSONValue = JSONValue,
Output extends JSONValue = JSONValue,
> extends Handler<Container, Input, Output> {
public handle = async (
public handle = async function* (
input: AsyncIterableIterator<Input>,
cancel: (reason?: any) => void,
meta: Record<string, JSONValue> | undefined,
ctx: ContextTimed,
): Promise<Output> => {
): AsyncIterableIterator<Output> {
throw new ErrorRPCMethodNotImplemented();
};
}
Expand Down
9 changes: 6 additions & 3 deletions src/handlers/RawHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { ErrorRPCMethodNotImplemented } from '../errors';

abstract class RawHandler<
Container extends ContainerType = ContainerType,
Input extends JSONValue = JSONValue, // Define Input type if needed
Output extends JSONValue = JSONValue, // Define Output type if needed
> extends Handler<Container> {
public handle = async (
input: [JSONRPCRequest, ReadableStream<Uint8Array>],
public handle = async function* (
input: AsyncIterableIterator<Input>, // Change this based on your specific needs
cancel: (reason?: any) => void,
meta: Record<string, JSONValue> | undefined,
ctx: ContextTimed,
): Promise<[JSONValue, ReadableStream<Uint8Array>]> => {
): AsyncIterableIterator<Output> {
// Change return type to AsyncIterableIterator
throw new ErrorRPCMethodNotImplemented('This method must be overridden');
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/UnaryHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ abstract class UnaryHandler<
Input extends JSONValue = JSONValue,
Output extends JSONValue = JSONValue,
> extends Handler<Container, Input, Output> {
public handle = async (
public handle = async function* (
input: Input,
cancel: (reason?: any) => void,
meta: Record<string, JSONValue> | undefined,
ctx: ContextTimed,
): Promise<Output> => {
): AsyncIterableIterator<Output> {
Comment on lines +11 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, why are you changing this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should stay as a Promise.

throw new ErrorRPCMethodNotImplemented('This method must be overridden');
};
}
Expand Down
7 changes: 2 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,8 @@ type ContainerType = Record<string, any>;
* mainly used as the return type for the `StreamFactory`. But the interface
* can be propagated across the RPC system.
*/
interface RPCStream<
R,
W,
M extends Record<string, JSONValue> = Record<string, JSONValue>,
> extends ReadableWritablePair<R, W> {
interface RPCStream<R, W, M extends POJO = POJO>
extends ReadableWritablePair<R, W> {
cancel: (reason?: any) => void;
meta?: M;
}
Expand Down