Skip to content

gRPC Service Improvements #106

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 7 commits into from
Aug 16, 2022
Merged

gRPC Service Improvements #106

merged 7 commits into from
Aug 16, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Aug 12, 2022

What was changed

  • Added operator and test services
  • 💥 Changed temporalio.workflow_service package to temporalio.service package
  • 💥 Changed Client.service to Client.workflow_service, Client.operator_service, and Client.test_service
  • Added Client.service_client which is just a combination of the three services and the raw connection
  • 💥 Changed static_headers to rpc_metadata on client constructor
  • Added optional rpc_metadata to every high-level and low-level gRPC call
  • Added optional rpc_timeout to every high-level and low-level gRPC call
  • Made grpc dependency completely optional
  • Updated docs and tests to support the above

The three backwards-incompatible changes are denoted with 💥. I know the review appears a bit daunting, but this is due to large refactoring I had to do. Externally it has minimal effect. The auto-generated proto files in temporalio/api can be ignored.

Checklist

  1. Closes Remove gRPC dependency #56
  2. Closes Expose operator service raw grpc API #93
  3. Closes Per-call gRPC options #101

@cretz cretz requested a review from a team August 12, 2022 19:05
@cretz cretz force-pushed the grpc-updates branch 6 times, most recently from 8f6b1e5 to f162dd1 Compare August 15, 2022 15:04
Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Seems like we could possibly save a lot of lines in the python client definitions with something a bit more generic/dynamic, but not a huge deal.

req: Vec<u8>,
retry: bool,
metadata: HashMap<String, String>,
timeout_millis: Option<u64>,
Copy link
Member

Choose a reason for hiding this comment

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

This could just be a duration directly, if pyo3 does that.

Copy link
Member Author

Choose a reason for hiding this comment

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

It doesn't. Ref https://pyo3.rs/v0.16.4/conversions/tables.html. I could take a timedelta directly and convert myself, but this is close enough and ms is decent resolution (note I have done this with all other durations to Rust).

@@ -73,7 +72,7 @@ async def connect(
] = None,
tls: Union[bool, TLSConfig] = False,
retry_config: Optional[RetryConfig] = None,
static_headers: Mapping[str, str] = {},
rpc_metadata: Mapping[str, str] = {},
Copy link
Member

Choose a reason for hiding this comment

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

I think it makes sense to call this just "headers" still, it's probably a more familiar term for a lot of users.

Copy link
Member Author

@cretz cretz Aug 15, 2022

Choose a reason for hiding this comment

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

Don't want to do that as we also have Temporal headers and this is a high-level API. It is important to know this high-level construct maps to low-level RPC metadata. Note, in the low-level calls I do remove the rpc_ prefix. As for "headers" vs "metadata", this matches TypeScript and makes sense from a gRPC perspective.

Comment on lines +755 to +757
rpc_timeout: Optional RPC deadline to set for each RPC call. Note,
this is the timeout for each history RPC call not this overall
function.
Copy link
Member

Choose a reason for hiding this comment

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

People won't realize what "history" means in this context. I'd just say "...underlying RPC call...".

Copy link
Member Author

Choose a reason for hiding this comment

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

Will change on next commit. I am a bit worried about confusion caused by this and if I should change to a fixed date time deadline, but I can wait until that is really needed.

@cretz cretz merged commit c965c47 into temporalio:main Aug 16, 2022
@cretz cretz deleted the grpc-updates branch August 16, 2022 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Per-call gRPC options Expose operator service raw grpc API Remove gRPC dependency
2 participants