forked from dapr/php-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add actor reentrancy support & reminder partitioning (dapr#112)
* Update actor configuration * Send token in requests * Add unit tests to test config * resolves dapr#97 too * Add that to the test too
- Loading branch information
1 parent
ea43e72
commit bf50ad8
Showing
5 changed files
with
114 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Dapr\Actors; | ||
|
||
/** | ||
* Class ReentrantConfig | ||
* @package Dapr\Actors | ||
*/ | ||
class ReentrantConfig | ||
{ | ||
public function __construct(public int|null $max_stack_depth = null) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Dapr\Middleware\Defaults; | ||
|
||
use Dapr\Middleware\IRequestMiddleware; | ||
use Dapr\Middleware\IResponseMiddleware; | ||
use Psr\Http\Message\RequestInterface; | ||
use Psr\Http\Message\ResponseInterface; | ||
|
||
/** | ||
* Class ActorToken | ||
* @package Dapr\Middleware\Defaults | ||
*/ | ||
class ActorToken implements IRequestMiddleware, IResponseMiddleware | ||
{ | ||
// this is intentionally left undefined in order to throw if the client is created before detecting a reentrant token | ||
public static array $token; | ||
|
||
public function request(RequestInterface $request): RequestInterface | ||
{ | ||
if ($request->hasHeader('Dapr-Reentrancy-Id')) { | ||
self::$token = $request->getHeader('Dapr-Reentrancy-Id'); | ||
} else { | ||
self::$token = []; | ||
} | ||
|
||
return $request; | ||
} | ||
|
||
public function response(ResponseInterface $response): ResponseInterface | ||
{ | ||
if (!empty(self::$token)) { | ||
return $response->withHeader('Dapr-Reentrancy-Id', self::$token); | ||
} | ||
|
||
return $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters