google.gax.api_callable¶
Provides function wrappers that implement page streaming and retrying.
Functions
construct_settings (service_name, …[, …]) |
Constructs a dictionary mapping method names to _CallSettings. |
create_api_call (func, settings) |
Converts an rpc call into an API call governed by the settings. |
-
construct_settings
(service_name, client_config, config_override, retry_names, bundle_descriptors=None, page_descriptors=None, metrics_headers=(), kwargs=None)[source]¶ Constructs a dictionary mapping method names to _CallSettings.
The
client_config
parameter is parsed from a client configuration JSON file of the form:{ "interfaces": { "google.fake.v1.ServiceName": { "retry_codes": { "idempotent": ["UNAVAILABLE", "DEADLINE_EXCEEDED"], "non_idempotent": [] }, "retry_params": { "default": { "initial_retry_delay_millis": 100, "retry_delay_multiplier": 1.2, "max_retry_delay_millis": 1000, "initial_rpc_timeout_millis": 2000, "rpc_timeout_multiplier": 1.5, "max_rpc_timeout_millis": 30000, "total_timeout_millis": 45000 } }, "methods": { "CreateFoo": { "retry_codes_name": "idempotent", "retry_params_name": "default", "timeout_millis": 30000 }, "Publish": { "retry_codes_name": "non_idempotent", "retry_params_name": "default", "bundling": { "element_count_threshold": 40, "element_count_limit": 200, "request_byte_threshold": 90000, "request_byte_limit": 100000, "delay_threshold_millis": 100 } } } } } }
Parameters: - service_name (str) – The fully-qualified name of this service, used as a
key into the client config file (in the example above, this value
would be
google.fake.v1.ServiceName
). - client_config (dict) – A dictionary parsed from the standard API client config file.
- bundle_descriptors (
Mapping
[str
,BundleDescriptor
]) – A dictionary of method names to BundleDescriptor objects for methods that are bundling-enabled. - page_descriptors (
Mapping
[str
,PageDescriptor
]) – A dictionary of method names to PageDescriptor objects for methods that are page streaming-enabled. - config_override (str) – A dictionary in the same structure of client_config to override the settings. Usually client_config is supplied from the default config and config_override will be specified by users.
- retry_names (
Mapping
[str
,object
]) – A dictionary mapping the strings referring to response status codes to the Python objects representing those codes. - metrics_headers (
Mapping
[str
,str
]) – Dictionary of headers to be passed for analytics. Sent as a dictionary; eventually becomes a space-separated string (e.g. ‘foo/1.0.0 bar/3.14.1’). - kwargs (dict) – The keyword arguments to be passed to the API calls.
Returns: A dictionary mapping method names to _CallSettings.
Return type: Raises: KeyError
– If the configuration for the service in question cannot be located in the providedclient_config
.- service_name (str) – The fully-qualified name of this service, used as a
key into the client config file (in the example above, this value
would be
-
create_api_call
(func, settings)[source]¶ Converts an rpc call into an API call governed by the settings.
In typical usage,
func
will be a callable used to make an rpc request. This will mostly likely be a bound method from a request stub used to make an rpc call.The result is created by applying a series of function decorators defined in this module to
func
.settings
is used to determine which function decorators to apply.The result is another callable which for most values of
settings
has has the same signature as the original. Only whensettings
configures bundling does the signature change.Parameters: Returns: - a bound method on a request stub used
to make an rpc call
Return type: Raises: ValueError
– ifsettings
has incompatible values, e.g, if bundling and page_streaming are both configured