diff --git a/src/Cache/Internal/DataGrpcManager.php b/src/Cache/Internal/DataGrpcManager.php index f697bb8..9e70921 100644 --- a/src/Cache/Internal/DataGrpcManager.php +++ b/src/Cache/Internal/DataGrpcManager.php @@ -32,6 +32,18 @@ public function __construct(ICredentialProvider $authProvider, IConfiguration $c if ($forceNewChannel) { $channelArgs["force_new"] = $forceNewChannel; } + if ($configuration->getTransportStrategy()->getGrpcConfig()->getKeepAlivePermitWithoutCalls()) { + $channelArgs["grpc.keepalive_permit_without_calls"] = + $configuration->getTransportStrategy()->getGrpcConfig()->getKeepAlivePermitWithoutCalls(); + } + if ($configuration->getTransportStrategy()->getGrpcConfig()->getKeepAliveTimeoutMS()) { + $channelArgs["grpc.keepalive_timeout_ms"] = + $configuration->getTransportStrategy()->getGrpcConfig()->getKeepAliveTimeoutMS(); + } + if ($configuration->getTransportStrategy()->getGrpcConfig()->getKeepAliveTimeMS()) { + $channelArgs["grpc.keepalive_time_ms"] = + $configuration->getTransportStrategy()->getGrpcConfig()->getKeepAliveTimeMS(); + } $this->channel = new Channel($endpoint, $channelArgs); $interceptors = [ new AuthorizationInterceptor($authProvider->getAuthToken()), diff --git a/src/Config/Configurations/Lambda.php b/src/Config/Configurations/Lambda.php new file mode 100644 index 0000000..f7649c1 --- /dev/null +++ b/src/Config/Configurations/Lambda.php @@ -0,0 +1,44 @@ +deadlineMilliseconds = $deadlineMilliseconds; $this->forceNewChannel = $forceNewChannel; $this->numGrpcChannels = $numGrpcChannels; + $this->keepAlivePermitWithoutCalls = $keepAlivePermitWithoutCalls; + $this->keepAliveTimeoutMS = $keepAliveTimeoutMS; + $this->keepAliveTimeMS = $keepAliveTimeMS; + } + + public function getKeepAlivePermitWithoutCalls(): ?int + { + return $this->keepAlivePermitWithoutCalls; + } + + public function getKeepAliveTimeoutMS(): ?int + { + return $this->keepAliveTimeoutMS; + } + + public function getKeepAliveTimeMS(): ?int + { + return $this->keepAliveTimeMS; } public function getDeadlineMilliseconds(): ?int diff --git a/src/Config/Transport/StaticStorageGrpcConfiguration.php b/src/Config/Transport/StaticStorageGrpcConfiguration.php index 3f27f37..913b326 100644 --- a/src/Config/Transport/StaticStorageGrpcConfiguration.php +++ b/src/Config/Transport/StaticStorageGrpcConfiguration.php @@ -9,12 +9,39 @@ class StaticStorageGrpcConfiguration implements IGrpcConfiguration private ?int $deadlineMilliseconds; private bool $forceNewChannel; private int $numGrpcChannels; + private ?int $keepAlivePermitWithoutCalls; + private ?int $keepAliveTimeoutMS; + private ?int $keepAliveTimeMS; - public function __construct(?int $deadlineMilliseconds = null, bool $forceNewChannel = false, int $numGrpcChannels = 1) - { + public function __construct( + ?int $deadlineMilliseconds = null, + bool $forceNewChannel = false, + int $numGrpcChannels = 1, + ?int $keepAlivePermitWithoutCalls = 0, + ?int $keepAliveTimeoutMS = null, + ?int $keepAliveTimeMS = null + ) { $this->deadlineMilliseconds = $deadlineMilliseconds; $this->forceNewChannel = $forceNewChannel; $this->numGrpcChannels = $numGrpcChannels; + $this->keepAlivePermitWithoutCalls = $keepAlivePermitWithoutCalls; + $this->keepAliveTimeoutMS = $keepAliveTimeoutMS; + $this->keepAliveTimeMS = $keepAliveTimeMS; + } + + public function getKeepAlivePermitWithoutCalls(): ?int + { + return $this->keepAlivePermitWithoutCalls; + } + + public function getKeepAliveTimeoutMS(): ?int + { + return $this->keepAliveTimeoutMS; + } + + public function getKeepAliveTimeMS(): ?int + { + return $this->keepAliveTimeMS; } public function getDeadlineMilliseconds(): ?int