Skip to content

Commit

Permalink
Merge pull request #892 from humanmade/backport-829-to-v12-branch
Browse files Browse the repository at this point in the history
[Backport v12-branch] Fix cavalcade runner memory usage leak
  • Loading branch information
jerico authored Sep 2, 2024
2 parents d60f421 + 10ae2ab commit e234808
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions inc/cavalcade_runner_to_cloudwatch/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,17 @@ function ( $name, $value ) {
* @return CloudWatchClient
*/
function cloudwatch_client() : CloudWatchClient {
return Altis\get_aws_sdk()->createCloudWatch( [
'version' => '2010-08-01',
'http' => [
'synchronous' => false,
],
] );
static $client;
if ( ! $client ) {
$client = Altis\get_aws_sdk()->createCloudWatch( [
'version' => '2010-08-01',
'http' => [
'synchronous' => false,
],
] );
}

return $client;
}

/**
Expand All @@ -172,12 +177,16 @@ function cloudwatch_client() : CloudWatchClient {
* @return CloudWatchLogsClient
*/
function cloudwatch_logs_client() : CloudWatchLogsClient {
return Altis\get_aws_sdk()->createCloudWatchLogs( [
'version' => '2014-03-28',
'http' => [
'synchronous' => true,
],
] );
static $client;
if ( ! $client ) {
$client = Altis\get_aws_sdk()->createCloudWatchLogs( [
'version' => '2014-03-28',
'http' => [
'synchronous' => true,
],
] );
}
return $client;
}

/**
Expand Down

0 comments on commit e234808

Please sign in to comment.