Skip to content

Commit

Permalink
fix(specs): endpoint level timeout for ingestion (#4251)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Dec 18, 2024
1 parent 7b827d2 commit 679a8cd
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def merge(
query_parameters: Optional[Dict[str, Any]] = None,
headers: Optional[Dict[str, str]] = None,
data: Optional[str] = None,
timeouts: Dict[str, int] = {},
user_request_options: Optional[Union[Self, Dict[str, Any]]] = None,
) -> Self:
"""
Expand All @@ -74,9 +75,9 @@ def merge(
"headers": headers,
"query_parameters": query_parameters,
"timeouts": {
"read": self._config.read_timeout,
"write": self._config.write_timeout,
"connect": self._config.connect_timeout,
"read": timeouts.get("read", self._config.read_timeout),
"write": timeouts.get("write", self._config.write_timeout),
"connect": timeouts.get("connect", self._config.connect_timeout),
},
"data": data,
}
Expand Down
4 changes: 4 additions & 0 deletions specs/ingestion/paths/sources/discover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ post:
- addObject
- deleteIndex
- editSettings
x-timeouts:
connect: 180000
read: 180000
write: 180000
parameters:
- $ref: '../../common/parameters.yml#/pathSourceID'
responses:
Expand Down
4 changes: 4 additions & 0 deletions specs/ingestion/paths/sources/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ post:
- addObject
- deleteIndex
- editSettings
x-timeouts:
connect: 180000
read: 180000
write: 180000
requestBody:
description: ''
content:
Expand Down
4 changes: 4 additions & 0 deletions specs/ingestion/paths/sources/validateID.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ post:
- addObject
- deleteIndex
- editSettings
x-timeouts:
connect: 180000
read: 180000
write: 180000
parameters:
- $ref: '../../common/parameters.yml#/pathSourceID'
requestBody:
Expand Down
4 changes: 4 additions & 0 deletions specs/ingestion/paths/tasks/v2/pushTask.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ post:
- addObject
- deleteIndex
- editSettings
x-timeouts:
connect: 180000
read: 180000
write: 180000
parameters:
- $ref: '../../../common/parameters.yml#/pathTaskID'
- name: watch
Expand Down
11 changes: 11 additions & 0 deletions templates/javascript/clients/api-single.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ export function create{{#lambda.titlecase}}{{clientName}}{{/lambda.titlecase}}({
{{/vendorExtensions}}
};

{{#vendorExtensions.x-timeouts}}
requestOptions = {
timeouts: {
connect: {{connect}},
read: {{read}},
write: {{write}},
...requestOptions?.timeouts,
}
}
{{/vendorExtensions.x-timeouts}}

return transporter.request(request, requestOptions);
},

Expand Down
7 changes: 7 additions & 0 deletions templates/python/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ class {{classname}}{{#isSyncClient}}Sync{{/isSyncClient}}:
{{#queryParams.0}}query_parameters=_query_parameters,{{/queryParams.0}}
{{#headerParams.0}}headers=_headers,{{/headerParams.0}}
{{#bodyParam}}data=dumps(body_serializer(_data)),{{/bodyParam}}
{{#vendorExtensions.x-timeouts}}
timeouts={
"read": {{read}},
"write": {{write}},
"connect": {{connect}},
},
{{/vendorExtensions.x-timeouts}}
user_request_options=request_options,
),
{{#vendorExtensions}}
Expand Down
5 changes: 4 additions & 1 deletion templates/ruby/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ module {{moduleName}}
{{/headerParams}}
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
{{/vendorExtensions}}
{{#vendorExtensions.x-timeouts}}
request_options[:timeout] ||= {{#vendorExtensions.x-use-read-transporter}}{{vendorExtensions.x-timeouts.read}}{{/vendorExtensions.x-use-read-transporter}} {{^vendorExtensions.x-use-read-transporter}}{{vendorExtensions.x-timeouts.write}}{{/vendorExtensions.x-use-read-transporter}}
{{/vendorExtensions.x-timeouts}}

post_body = request_options[:debug_body]{{#bodyParam}} || @api_client.object_to_http_body({{{paramName}}}){{/bodyParam}}

Expand Down Expand Up @@ -187,4 +190,4 @@ module {{moduleName}}
{{/isSearchClient}}
end
{{/operations}}
end
end

0 comments on commit 679a8cd

Please sign in to comment.