-
Notifications
You must be signed in to change notification settings - Fork 0
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
Factoring out the Timeout Middleware from PK to js-rpc #19
Comments
I believe the https://github.com/MatrixAI/Polykey/blob/staging/src/client/timeoutMiddleware.ts This should really be in js-rpc. I think this (https://github.com/MatrixAI/Polykey/blob/staging/src/client/types.ts): // Prevent overwriting the metadata type with `Omit<>`
type ClientRPCRequestParams<T extends Record<string, JSONValue> = ObjectEmpty> =
{
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
timeout: number;
}>;
} & Omit<T, 'metadata'>;
// Prevent overwriting the metadata type with `Omit<>`
type ClientRPCResponseResult<
T extends Record<string, JSONValue> = ObjectEmpty,
> = {
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
timeout: number;
}>;
} & Omit<T, 'metadata'>; This can be part of the js-rpc library as well. The only thing imposition here is simply the fact that js-rpc says we need to reserve the |
If you want to make it flexible it can be parameterised as the "reserved key". |
ATM the agent service is not using the timeout middleware at all, and it should be. So there needs to be a fix here too. |
You can work on this @addievo and start a PR here and a PR in Polykey, they should be kept in sync. |
Note that this is incorrect: // Prevent overwriting the metadata type with `Omit<>`
type AgentRPCRequestParams<T extends Record<string, JSONValue> = ObjectEmpty> =
{
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
timeout: number;
}>;
} & Omit<T, 'metadata'>;
// Prevent overwriting the metadata type with `Omit<>`
type AgentRPCResponseResult<T extends Record<string, JSONValue> = ObjectEmpty> =
{
metadata?: {
[Key: string]: JSONValue;
} & Partial<{
authorization: string;
timeout: number;
}>;
} & Omit<T, 'metadata'>; The |
This is part of #551, and we want to make sure this is ready by mid next week. |
Alright, just imported
|
They should not have the Client prefix anymore. It is generic now. |
Remember this too. |
Timeout middleware on chunk.params doesn't make much sense in rpc context as in PK we assumed all values to be a valid JSON, but in RPC they aren't, consequently, while the middleware is now working in rpc, many jests are failing due to the same. And therefore it would make more sense on |
I don't know what you mean. |
|
Specification
Factor out the timeout middleware.
Tasks
ClientRPCRequestParams
as an extension of the default request and response types. You can create a more specific subtype when usingextends
here. This applies also toAgentRPCRequestParams
and associated.The text was updated successfully, but these errors were encountered: