-
Notifications
You must be signed in to change notification settings - Fork 613
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert D67328763: Delete thrift py3 services reflection
Differential Revision: D67328763 Original commit changeset: 332a2d4b8c8c Original Phabricator Diff: D67328763 fbshipit-source-id: 156592ddc1708b373e9f029c85d03e29ad1e9399
- Loading branch information
1 parent
4c4ad3c
commit addb3d0
Showing
105 changed files
with
6,252 additions
and
141 deletions.
There are no files selected for viewing
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
File renamed without changes.
96 changes: 96 additions & 0 deletions
96
thrift/compiler/generate/templates/py3/services_reflection.py.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,96 @@ | ||
{{! | ||
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. | ||
}}{{! | ||
Reflection functions for clients and services | ||
}} | ||
{{> common/auto_generated_py}} | ||
|
||
from thrift.py3.reflection import ( | ||
ArgumentSpec as __ArgumentSpec, | ||
InterfaceSpec as __InterfaceSpec, | ||
MethodSpec as __MethodSpec, | ||
NumberType as __NumberType, | ||
) | ||
|
||
import folly.iobuf as _fbthrift_iobuf | ||
|
||
{{#program:includeNamespaces}} | ||
{{#hasTypes?}} | ||
import {{#includeNamespace}}{{value}}.{{/includeNamespace}}types as _{{#includeNamespace}}{{value}}_{{/includeNamespace}}types | ||
{{/hasTypes?}} | ||
{{/program:includeNamespaces}} | ||
|
||
import {{#program:py3Namespaces}}{{value}}.{{/program:py3Namespaces}}{{program:name}}.types as _{{#program:py3Namespaces}}{{value}}_{{/program:py3Namespaces}}{{program:name}}_types | ||
{{#program:services}} | ||
|
||
|
||
def get_reflection__{{service:name}}(for_clients: bool): | ||
spec: __InterfaceSpec = __InterfaceSpec( | ||
name="{{service:name}}", | ||
methods=None, | ||
annotations={ | ||
{{#service:annotations}} | ||
{{> common/annotation }} | ||
{{/service:annotations}} | ||
}, | ||
) | ||
{{#service:supportedFunctions}} | ||
spec.add_method( | ||
__MethodSpec.__new__( | ||
__MethodSpec, | ||
name="{{function:name}}", | ||
arguments=( | ||
{{#function:args}} | ||
__ArgumentSpec.__new__( | ||
__ArgumentSpec, | ||
name="{{field:name}}", | ||
type={{#field:type}}{{> types/python_type}}{{/field:type}}, | ||
kind={{#field:type}}{{> types/thrift_number_type}}{{/field:type}}, | ||
annotations={ | ||
{{#field:annotations}} | ||
{{> common/annotation }} | ||
{{/field:annotations}} | ||
}, | ||
), | ||
{{/function:args}} | ||
), | ||
result={{#function:return_type}}{{! | ||
}}{{#type:void?}}{{^function:stream?}}None{{/function:stream?}}{{/type:void?}}{{! | ||
}}{{#function:stream?}}{{! | ||
}}{{> clients/stream_response_class_name}} if for_clients else {{! | ||
}}{{> services/stream_response_class_name}}{{! | ||
}}{{/function:stream?}}{{! | ||
}}{{^type:void?}}{{^function:stream?}}{{> types/python_type}}{{/function:stream?}}{{/type:void?}}{{! | ||
}}{{/function:return_type}}, | ||
result_kind={{#function:return_type}}{{! | ||
}}{{^function:stream?}}{{> types/thrift_number_type}}{{/function:stream?}}{{! | ||
}}{{#function:stream?}}__NumberType.NOT_A_NUMBER{{/function:stream?}}{{/function:return_type}}, | ||
exceptions=( | ||
{{#function:exceptions}} | ||
{{#field:type}}{{> types/python_type}}{{/field:type}}, | ||
{{/function:exceptions}} | ||
), | ||
annotations={ | ||
{{#function:annotations}} | ||
{{> common/annotation }} | ||
{{/function:annotations}} | ||
}, | ||
) | ||
) | ||
{{/service:supportedFunctions}} | ||
return spec | ||
{{/program:services}} |
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
File renamed without changes.
Oops, something went wrong.