Skip to content

Commit

Permalink
chore: add Lambda configuration with values ported from nodejs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgautier404 committed Nov 21, 2024
1 parent 2394b93 commit 4cd8ebd
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Config/Configurations/Lambda.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
declare(strict_types=1);

namespace Momento\Config\Configurations;

use Momento\Config\Configuration;
use Momento\Config\ReadConcern;
use Momento\Config\Transport\StaticGrpcConfiguration;
use Momento\Config\Transport\StaticStorageTransportStrategy;
use Momento\Logging\ILoggerFactory;
use Momento\Logging\NullLoggerFactory;

/**
* Lambda config provides recommended configuration settings for a lambda environment.
*/
class Lambda extends Configuration
{
/**
* Provides the latest recommended configuration for a Lambda environment.
* This configuration may change in future releases to take advantage of
* improvements we identify for default configurations.
* @param ILoggerFactory|null $loggerFactory
* @return Lambda
*/
public static function latest(?ILoggerFactory $loggerFactory = null): Lambda
{
return self::v1($loggerFactory);
}

/**
* Provides the version 1 configuration for a Lambda environment. This configuration is guaranteed not to change
* in future releases of the SDK.
* @param ILoggerFactory|null $loggerFactory
* @return Lambda
*/
public static function v1(?ILoggerFactory $loggerFactory = null): Lambda
{
$loggerFactory = $loggerFactory ?? new NullLoggerFactory();
$grpcConfig = new StaticGrpcConfiguration(1100);
$transportStrategy = new StaticStorageTransportStrategy($grpcConfig, $loggerFactory, self::$maxIdleMillis);
$readConcern = ReadConcern::BALANCED;
return new Lambda($loggerFactory, $transportStrategy, $readConcern);
}
}

0 comments on commit 4cd8ebd

Please sign in to comment.