-
Notifications
You must be signed in to change notification settings - Fork 2
Implement RPC timeouts #123
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7a05373
Bubbling out single-use stream parameter
blast-hardcheese 65c1689
Typing create_task parameters to avoid Unknown
blast-hardcheese bc515c3
The only tasks we end up dealing with are Task[None]
blast-hardcheese 0a1262c
Implement RPC timeouts
blast-hardcheese a02d6e0
Adding an RPC codegen test
blast-hardcheese a75534b
Only codegen for tests once per pytest invocation
blast-hardcheese abe4fda
Add a test for timeout
blast-hardcheese 187a487
Fix exception
blast-hardcheese f5de68b
Adding a stream test
blast-hardcheese File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Code generated by river.codegen. DO NOT EDIT. | ||
| from pydantic import BaseModel | ||
| from typing import Literal | ||
|
|
||
| import replit_river as river | ||
|
|
||
|
|
||
| from .test_service import Test_ServiceService | ||
|
|
||
|
|
||
| class RpcClient: | ||
| def __init__(self, client: river.Client[Literal[None]]): | ||
| self.test_service = Test_ServiceService(client) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Code generated by river.codegen. DO NOT EDIT. | ||
| from collections.abc import AsyncIterable, AsyncIterator | ||
| from typing import Any | ||
| import datetime | ||
|
|
||
| from pydantic import TypeAdapter | ||
|
|
||
| from replit_river.error_schema import RiverError | ||
| import replit_river as river | ||
|
|
||
|
|
||
| from .rpc_method import encode_Rpc_MethodInput, Rpc_MethodInput, Rpc_MethodOutput | ||
|
|
||
|
|
||
| class Test_ServiceService: | ||
| def __init__(self, client: river.Client[Any]): | ||
| self.client = client | ||
|
|
||
| async def rpc_method( | ||
| self, | ||
| input: Rpc_MethodInput, | ||
| timeout: datetime.timedelta, | ||
| ) -> Rpc_MethodOutput: | ||
| return await self.client.send_rpc( | ||
| "test_service", | ||
| "rpc_method", | ||
| input, | ||
| encode_Rpc_MethodInput, | ||
| lambda x: TypeAdapter(Rpc_MethodOutput).validate_python( | ||
| x # type: ignore[arg-type] | ||
| ), | ||
| lambda x: TypeAdapter(RiverError).validate_python( | ||
| x # type: ignore[arg-type] | ||
| ), | ||
| timeout, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # ruff: noqa | ||
| # Code generated by river.codegen. DO NOT EDIT. | ||
| from collections.abc import AsyncIterable, AsyncIterator | ||
| import datetime | ||
| from typing import ( | ||
| Any, | ||
| Callable, | ||
| Dict, | ||
| List, | ||
| Literal, | ||
| Optional, | ||
| Mapping, | ||
| Union, | ||
| Tuple, | ||
| TypedDict, | ||
| ) | ||
|
|
||
| from pydantic import BaseModel, Field, TypeAdapter | ||
| from replit_river.error_schema import RiverError | ||
|
|
||
| import replit_river as river | ||
|
|
||
|
|
||
| encode_Rpc_MethodInput: Callable[["Rpc_MethodInput"], Any] = lambda x: { | ||
| k: v | ||
| for (k, v) in ( | ||
| { | ||
| "data": x.get("data"), | ||
| } | ||
| ).items() | ||
| if v is not None | ||
| } | ||
|
|
||
|
|
||
| class Rpc_MethodInput(TypedDict): | ||
| data: str | ||
|
|
||
|
|
||
| class Rpc_MethodOutput(BaseModel): | ||
| data: str |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "services": { | ||
| "test_service": { | ||
| "procedures": { | ||
| "rpc_method": { | ||
| "input": { | ||
| "type": "object", | ||
| "properties": { | ||
| "data": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": ["data"] | ||
| }, | ||
| "output": { | ||
| "type": "object", | ||
| "properties": { | ||
| "data": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "required": ["data"] | ||
| }, | ||
| "errors": { | ||
| "not": {} | ||
| }, | ||
| "type": "rpc" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Code generated by river.codegen. DO NOT EDIT. | ||
| from pydantic import BaseModel | ||
| from typing import Literal | ||
|
|
||
| import replit_river as river | ||
|
|
||
|
|
||
| from .test_service import Test_ServiceService | ||
|
|
||
|
|
||
| class StreamClient: | ||
| def __init__(self, client: river.Client[Literal[None]]): | ||
| self.test_service = Test_ServiceService(client) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Code generated by river.codegen. DO NOT EDIT. | ||
| from collections.abc import AsyncIterable, AsyncIterator | ||
| from typing import Any | ||
| import datetime | ||
|
|
||
| from pydantic import TypeAdapter | ||
|
|
||
| from replit_river.error_schema import RiverError | ||
| import replit_river as river | ||
|
|
||
|
|
||
| from .stream_method import ( | ||
| encode_Stream_MethodInput, | ||
| Stream_MethodOutput, | ||
| Stream_MethodInput, | ||
| ) | ||
|
|
||
|
|
||
| class Test_ServiceService: | ||
| def __init__(self, client: river.Client[Any]): | ||
| self.client = client | ||
|
|
||
| async def stream_method( | ||
| self, | ||
| inputStream: AsyncIterable[Stream_MethodInput], | ||
| ) -> AsyncIterator[Stream_MethodOutput | RiverError]: | ||
| return self.client.send_stream( | ||
| "test_service", | ||
| "stream_method", | ||
| None, | ||
| inputStream, | ||
| None, | ||
| encode_Stream_MethodInput, | ||
| lambda x: TypeAdapter(Stream_MethodOutput).validate_python( | ||
| x # type: ignore[arg-type] | ||
| ), | ||
| lambda x: TypeAdapter(RiverError).validate_python( | ||
| x # type: ignore[arg-type] | ||
| ), | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.