-
Notifications
You must be signed in to change notification settings - Fork 611
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: In order to "properly" migrate from ThreadManager to ResourcePools in the underlying C++ thrift server, we need to generate method metadata maps. nhawkes got started with this diff and made great progress, but I have the bandwidth to put the rest of it together, so I'm taking over the diff. So instead of pushing ALL of the MethodMetadata generation to the codegenerated code, I'm just pushing the following fields 1. RpcKind 2. InteractionType 3. Name 4. Starts-interaction 5. Interaction name The others, we want 100% owned by Rust Thrift's srserver implementation (i.e. ExecutorType). These are not something Rust thrift services should codegen, or have any control of in the code generation phases as they are configurable when setting up a thrift server. NOTE: Overriding the thrift request priority MAY come at a future date, which comes through annotations. Presently it is NOT supported. Also: Regenerating the test-fixtures with `cd ~/fbsource/fbcode && buck run fbcode//thrift/compiler/test:build_fixtures` Reviewed By: tlj77 Differential Revision: D65489886 Privacy Context Container: L1122763 fbshipit-source-id: c54f8a3acbe6af3ee39e944bf75ac3f546000257
- Loading branch information
1 parent
df63de4
commit 3a374b2
Showing
20 changed files
with
1,179 additions
and
226 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
thrift/compiler/generate/templates/rust/lib/method_metadata.mustache
This file contains 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,70 @@ | ||
{{! | ||
Copyright (c) Meta Platforms, Inc. and affiliates. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
}} | ||
// From {{service:program_name}}.{{service:name}}: | ||
{{^service:interaction?}} | ||
{{#service:rustFunctions}} | ||
::fbthrift::processor::MethodMetadata{ | ||
interaction_type: ::fbthrift::processor::InteractionType::None, | ||
{{#function:stream?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, | ||
{{/function:stream?}} | ||
{{^function:stream?}}{{#function:sink?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINK, | ||
{{/function:sink?}}{{/function:stream?}} | ||
{{^function:stream?}}{{^function:sink?}} | ||
{{#function:return_type}}{{#type:void?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, | ||
{{/type:void?}}{{^type:void?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, | ||
{{/type:void?}}{{/function:return_type}} | ||
{{/function:sink?}}{{/function:stream?}} | ||
name: "{{function:name}}", | ||
starts_interaction: {{#function:starts_interaction?}}true{{/function:starts_interaction?}}{{^function:starts_interaction?}}false{{/function:starts_interaction?}}, | ||
interaction_name: {{#function:starts_interaction?}}Some("{{service:name}}"){{/function:starts_interaction?}}{{^function:starts_interaction?}}None{{/function:starts_interaction?}}, | ||
}, | ||
{{/service:rustFunctions}} | ||
{{#service:interactions}}{{#service:rustFunctions}} | ||
::fbthrift::processor::MethodMetadata{ | ||
interaction_type: ::fbthrift::processor::InteractionType::InteractionV1, | ||
{{#function:stream?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_STREAMING_RESPONSE, | ||
{{/function:stream?}} | ||
{{^function:stream?}}{{#function:sink?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINK, | ||
{{/function:sink?}}{{/function:stream?}} | ||
{{^function:stream?}}{{^function:sink?}} | ||
{{#function:return_type}}{{#type:void?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_NO_RESPONSE, | ||
{{/type:void?}}{{^type:void?}} | ||
rpc_kind: ::fbthrift::processor::RpcKind::SINGLE_REQUEST_SINGLE_RESPONSE, | ||
{{/type:void?}}{{/function:return_type}} | ||
{{/function:sink?}}{{/function:stream?}} | ||
name: "{{service:name}}.{{function:name}}", | ||
starts_interaction: false, | ||
interaction_name: Some("{{service:name}}"), | ||
}, | ||
{{/service:rustFunctions}}{{/service:interactions}} | ||
{{/service:interaction?}} | ||
{{#service:interaction?}} | ||
// Interaction's method names are never queried directly. | ||
// They are always queried from the "main" processor. | ||
{{/service:interaction?}} | ||
{{#service:extends}} | ||
|
||
{{>lib/method_metadata}} | ||
{{/service:extends}} |
34 changes: 0 additions & 34 deletions
34
thrift/compiler/generate/templates/rust/lib/method_names.mustache
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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
Oops, something went wrong.