Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move max idle millis to a static var in Configuation #141

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Config/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Configuration implements IConfiguration

private ?ILoggerFactory $loggerFactory;
private ?ITransportStrategy $transportStrategy;
protected static int $maxIdleMillis = 4 * 60 * 1000;

public function __construct(?ILoggerFactory $loggerFactory, ?ITransportStrategy $transportStrategy)
{
Expand Down
6 changes: 1 addition & 5 deletions src/Config/Configurations/InRegion.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
use Momento\Logging\ILoggerFactory;
use Momento\Logging\NullLoggerFactory;

const MAX_IDLE_MILLIS = 4 * 60 * 1000;

/**
* InRegion provides defaults suitable for an environment where your client is running in the same region as the Momento
* service. It has more aggressive timeouts and retry behavior than the Laptop config.
*/
class InRegion extends Configuration
{

/**
* Provides the latest recommended configuration for an InRegion environment.
* This configuration may change in future releases to take advantage of
Expand All @@ -42,8 +39,7 @@ public static function v1(?ILoggerFactory $loggerFactory = null): Laptop
{
$loggerFactory = $loggerFactory ?? new NullLoggerFactory();
$grpcConfig = new StaticGrpcConfiguration(1100);
$transportStrategy = new StaticTransportStrategy(null, $grpcConfig, $loggerFactory, MAX_IDLE_MILLIS);
$transportStrategy = new StaticTransportStrategy(null, $grpcConfig, $loggerFactory, self::$maxIdleMillis);
return new Laptop($loggerFactory, $transportStrategy);
}

}
6 changes: 1 addition & 5 deletions src/Config/Configurations/Laptop.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@
use Momento\Logging\ILoggerFactory;
use Momento\Logging\NullLoggerFactory;

const MAX_IDLE_MILLIS = 4 * 60 * 1000;

/**
* Laptop config provides defaults suitable for a medium-to-high-latency dev environment. Permissive timeouts, retries, and
* relaxed latency and throughput targets.
*/
class Laptop extends Configuration
{

/**
* Provides the latest recommended configuration for a Laptop environment.
*
Expand All @@ -40,8 +37,7 @@ public static function v1(?ILoggerFactory $loggerFactory = null): Laptop
{
$loggerFactory = $loggerFactory ?? new NullLoggerFactory();
$grpcConfig = new StaticGrpcConfiguration(5000);
$transportStrategy = new StaticTransportStrategy(null, $grpcConfig, $loggerFactory, MAX_IDLE_MILLIS);
$transportStrategy = new StaticTransportStrategy(null, $grpcConfig, $loggerFactory, self::$maxIdleMillis);
return new Laptop($loggerFactory, $transportStrategy);
}

}