Skip to content

Commit 318e9c6

Browse files
committed
6871: Fixed merge
2 parents 8c7441c + 50073e0 commit 318e9c6

10 files changed

Lines changed: 28 additions & 20 deletions

File tree

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ REDIS_CACHE_PREFIX=DisplayApiService
6161
REDIS_CACHE_DSN=redis://redis:6379/0
6262
###< redis ###
6363

64+
###> Http Client ###
65+
HTTP_CLIENT_TIMEOUT=5
66+
HTTP_CLIENT_MAX_DURATION=30
67+
###< Http Client ###
68+
6469
###> App ###
6570
DEFAULT_DATE_FORMAT='Y-m-d\TH:i:s.v\Z'
6671
ACTIVATION_CODE_EXPIRE_INTERVAL=P2D

config/packages/framework.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ framework:
1414
cookie_samesite: lax
1515
storage_factory_id: session.storage.factory.native
1616

17+
http_client:
18+
default_options:
19+
timeout: '%env(float:HTTP_CLIENT_TIMEOUT)%'
20+
max_duration: '%env(float:HTTP_CLIENT_MAX_DURATION)%'
21+
1722
#esi: true
1823
#fragments: true
1924
php_errors:

config/packages/prod/cache.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
cache:
3+
app: cache.adapter.redis

docs/v2-changelogs/api.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
- [#379](https://github.com/os2display/display-api-service/pull/379)
8+
- Ensure the http client has a default time out setting. Make it configurable in env.
9+
- [#376](https://github.com/os2display/display-api-service/pull/376)
10+
- Add prod override for cache.app to use Redis in production.
11+
712
## [2.6.1] - 2026-03-10
813

914
- [#347](https://github.com/os2display/display-api-service/pull/347)

infrastructure/itkdev/display-api-service/etc/confd/templates/env.local.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ CALENDAR_API_FEED_SOURCE_CACHE_EXPIRE_SECONDS={{ getenv "APP_CALENDAR_API_FEED_S
6565

6666
EVENTDATABASE_API_V2_CACHE_EXPIRE_SECONDS={{ getenv "APP_EVENTDATABASE_API_V2_CACHE_EXPIRE_SECONDS" "300" }}
6767

68+
###> Http Client ###
69+
HTTP_CLIENT_TIMEOUT={{ getenv "APP_HTTP_CLIENT_TIMEOUT" "5" }}
70+
HTTP_CLIENT_MAX_DURATION={{ getenv "APP_HTTP_CLIENT_MAX_DURATION" "30" }}
71+
###< Http Client ###
72+
6873
TRACK_SCREEN_INFO={{ getenv "APP_TRACK_SCREEN_INFO" "false" }}
6974
TRACK_SCREEN_INFO_UPDATE_INTERVAL_SECONDS={{ getenv "APP_TRACK_SCREEN_INFO_UPDATE_INTERVAL_SECONDS" "300" }}
7075

infrastructure/os2display/display-api-service/etc/confd/templates/env.local.tmpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ CALENDAR_API_FEED_SOURCE_CACHE_EXPIRE_SECONDS={{ getenv "CALENDAR_API_FEED_SOURC
6565

6666
EVENTDATABASE_API_V2_CACHE_EXPIRE_SECONDS={{ getenv "APP_EVENTDATABASE_API_V2_CACHE_EXPIRE_SECONDS" "300" }}
6767

68+
###> Http Client ###
69+
HTTP_CLIENT_TIMEOUT={{ getenv "APP_HTTP_CLIENT_TIMEOUT" "5" }}
70+
HTTP_CLIENT_MAX_DURATION={{ getenv "APP_HTTP_CLIENT_MAX_DURATION" "30" }}
71+
###< Http Client ###
72+
6873
TRACK_SCREEN_INFO={{ getenv "APP_TRACK_SCREEN_INFO" "false" }}
6974
TRACK_SCREEN_INFO_UPDATE_INTERVAL_SECONDS={{ getenv "APP_TRACK_SCREEN_INFO_UPDATE_INTERVAL_SECONDS" "300" }}
7075

src/Feed/EventDatabaseApiFeedType.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
class EventDatabaseApiFeedType implements FeedTypeInterface
2323
{
2424
final public const string SUPPORTED_FEED_TYPE = FeedOutputModels::POSTER_OUTPUT;
25-
final public const int REQUEST_TIMEOUT = 10;
2625

2726
public function __construct(
2827
private readonly FeedService $feedService,
@@ -72,7 +71,6 @@ public function getData(Feed $feed): array
7271
'GET',
7372
"$host/api/events",
7473
[
75-
'timeout' => self::REQUEST_TIMEOUT,
7674
'query' => $queryParams,
7775
]
7876
);
@@ -88,9 +86,6 @@ public function getData(Feed $feed): array
8886
$response = $this->client->request(
8987
'GET',
9088
"$host$occurrenceId",
91-
[
92-
'timeout' => self::REQUEST_TIMEOUT,
93-
]
9489
);
9590

9691
$content = $response->getContent();
@@ -200,9 +195,6 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
200195
$response = $this->client->request(
201196
'GET',
202197
"$host$path",
203-
[
204-
'timeout' => self::REQUEST_TIMEOUT,
205-
]
206198
);
207199

208200
$content = $response->getContent();
@@ -247,7 +239,6 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
247239
'GET',
248240
"$host/api/$type",
249241
[
250-
'timeout' => self::REQUEST_TIMEOUT,
251242
'query' => $queryParams,
252243
]
253244
);

src/Feed/EventDatabaseApiV2Helper.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
class EventDatabaseApiV2Helper
1818
{
19-
final public const int REQUEST_TIMEOUT = 10;
20-
2119
public function __construct(
2220
private readonly HttpClientInterface $client,
2321
) {}
@@ -34,7 +32,6 @@ public function request(FeedSource $feedSource, string $entityType, ?array $quer
3432
$apikey = $secrets['apikey'];
3533

3634
$options = [
37-
'timeout' => self::REQUEST_TIMEOUT,
3835
'headers' => [
3936
'X-Api-Key' => $apikey,
4037
],

src/Feed/NotifiedFeedType.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
class NotifiedFeedType implements FeedTypeInterface
1919
{
2020
final public const string SUPPORTED_FEED_TYPE = FeedOutputModels::INSTAGRAM_OUTPUT;
21-
final public const int REQUEST_TIMEOUT = 10;
2221

2322
private const string BASE_URL = 'https://api.listen.notified.com';
2423

@@ -147,7 +146,6 @@ public function getMentions(string $token, int $page = 1, int $pageSize = 10, ar
147146
'POST',
148147
self::BASE_URL.'/api/listen/mentions',
149148
[
150-
'timeout' => self::REQUEST_TIMEOUT,
151149
'headers' => [
152150
'Accept' => 'application/json',
153151
'Content-Type' => 'application/json',
@@ -166,7 +164,6 @@ public function getSearchProfiles(string $token): array
166164
'GET',
167165
self::BASE_URL.'/api/listen/searchprofiles',
168166
[
169-
'timeout' => self::REQUEST_TIMEOUT,
170167
'headers' => [
171168
'Accept' => 'application/json',
172169
'Content-Type' => 'application/json',

src/Feed/SparkleIOFeedType.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ class SparkleIOFeedType implements FeedTypeInterface
2424
{
2525
final public const string SUPPORTED_FEED_TYPE = FeedOutputModels::INSTAGRAM_OUTPUT;
2626

27-
final public const int REQUEST_TIMEOUT = 10;
28-
2927
public function __construct(
3028
private readonly FeedService $feedService,
3129
private readonly HttpClientInterface $client,
@@ -60,7 +58,6 @@ public function getData(Feed $feed): array
6058
'GET',
6159
$baseUrl.'v0.1/feed/'.$configuration['feeds'][0],
6260
[
63-
'timeout' => self::REQUEST_TIMEOUT,
6461
'headers' => [
6562
'Authorization' => sprintf('Bearer %s', $token),
6663
],
@@ -130,7 +127,6 @@ public function getConfigOptions(Request $request, FeedSource $feedSource, strin
130127
'GET',
131128
$baseUrl.'v0.1/feed',
132129
[
133-
'timeout' => self::REQUEST_TIMEOUT,
134130
'headers' => [
135131
'Authorization' => sprintf('Bearer %s', $token),
136132
],
@@ -222,7 +218,6 @@ private function getToken(string $baseUrl, string $clientId, string $clientSecre
222218
'POST',
223219
$baseUrl.'oauth/token',
224220
[
225-
'timeout' => self::REQUEST_TIMEOUT,
226221
'headers' => [
227222
'Content-Type' => 'application/x-www-form-urlencoded',
228223
],

0 commit comments

Comments
 (0)