-
Notifications
You must be signed in to change notification settings - Fork 0
update time library and misc fixes #74
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| module durable_php | ||
|
|
||
| go 1.22 | ||
| go 1.23 | ||
|
|
||
| require github.com/dunglas/frankenphp v1.2.5 | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ | |
| use Ramsey\Uuid\Uuid; | ||
| use ReflectionClass; | ||
| use ReflectionFunction; | ||
| use Withinboredom\Time\TimeUnit; | ||
|
|
||
| require_once __DIR__ . '/autoload.php'; | ||
|
|
||
|
|
@@ -85,18 +86,21 @@ public function __construct(private DurableLogger $logger) | |
| $this->method = $_SERVER['HTTP_DPHP_FUNCTION']; | ||
| try { | ||
| $provenance = json_decode($_SERVER['HTTP_DPHP_PROVENANCE'] ?? 'null', true, 32, JSON_THROW_ON_ERROR); | ||
| if (! $provenance || $provenance === ['userId' => '', 'roles' => null]) { | ||
| if (!$provenance || $provenance === ['userId' => '', 'roles' => null]) { | ||
| $this->provenance = null; | ||
| } else { | ||
| $provenance['roles'] ??= []; | ||
| $this->provenance = Serializer::deserialize($provenance, Provenance::class); | ||
| } | ||
| } catch (JsonException $e) { | ||
| $this->logger->alert('Failed to capture provenance', ['provenance' => $_SERVER['HTTP_DPHP_PROVENANCE'] ?? null]); | ||
| $this->logger->alert( | ||
| 'Failed to capture provenance', | ||
| ['provenance' => $_SERVER['HTTP_DPHP_PROVENANCE'] ?? null], | ||
|
Comment on lines
+96
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for JSON decoding error handling. The JSON decoding error handling logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| ); | ||
| $this->provenance = null; | ||
| } | ||
|
|
||
| if (! file_exists($_SERVER['HTTP_DPHP_PAYLOAD'])) { | ||
| if (!file_exists($_SERVER['HTTP_DPHP_PAYLOAD'])) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for payload file existence check. The payload file existence check logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| throw new LogicException('Unable to load payload'); | ||
| } | ||
|
|
||
|
|
@@ -186,14 +190,20 @@ public function outputEvent(EventDescription $event): void | |
|
|
||
| private function startOrchestration(): void | ||
| { | ||
| if (! $this->target->toOrchestrationInstance()->executionId) { | ||
| $this->target = StateId::fromInstance(new OrchestrationInstance($this->target->toOrchestrationInstance()->instanceId, Uuid::uuid7()->toString())); | ||
| if (!$this->target->toOrchestrationInstance()->executionId) { | ||
| $this->target = StateId::fromInstance( | ||
| new OrchestrationInstance( | ||
| $this->target->toOrchestrationInstance()->instanceId, | ||
| Uuid::uuid7()->toString(), | ||
| ), | ||
|
Comment on lines
+193
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for orchestration instance creation. The orchestration instance creation logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| ); | ||
| } | ||
|
|
||
| header('X-Id: ' . $this->target->id); | ||
| $input = SerializedArray::import($this->payload['input'])->toArray(); | ||
|
|
||
| $event = WithOrchestration::forInstance($this->target, StartExecution::asParent($input, []/* todo: scheduling */)); | ||
| $event = | ||
| WithOrchestration::forInstance($this->target, StartExecution::asParent($input, []/* todo: scheduling */)); | ||
|
Comment on lines
+205
to
+206
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for event creation. The event creation logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| $this->outputEvent(new EventDescription($event)); | ||
|
|
||
| $actualId = $this->target->toOrchestrationInstance(); | ||
|
|
@@ -301,19 +311,16 @@ private function getPermissions(): void | |
| $permissions['mode'] = 'anon'; | ||
| break; | ||
| case $attribute->getName() === AllowCreateForRole::class: | ||
| /** @var AllowCreateForRole $attribute */ | ||
| $attribute = $attribute->newInstance(); | ||
| /** @var AllowCreateForRole $attribute */ $attribute = $attribute->newInstance(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for role permissions. The role permissions logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| $permissions['roles'][] = $attribute->role; | ||
| break; | ||
| case $attribute->getName() === AllowCreateForUser::class: | ||
| /** @var AllowCreateForUser $attribute */ | ||
| $attribute = $attribute->newInstance(); | ||
| /** @var AllowCreateForUser $attribute */ $attribute = $attribute->newInstance(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for user permissions. The user permissions logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| $permissions['users'][] = $attribute->user; | ||
| break; | ||
| case $attribute->getName() === TimeToLive::class: | ||
| /** @var TimeToLive $attribute */ | ||
| $attribute = $attribute->newInstance(); | ||
| $permissions['ttl'] = $attribute->timeToLive()->inNanoseconds(); | ||
| /** @var TimeToLive $attribute */ $attribute = $attribute->newInstance(); | ||
| $permissions['ttl'] = $attribute->timeToLive()->as(TimeUnit::Nanoseconds); | ||
|
Comment on lines
+322
to
+323
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reminder: Add tests for time-to-live attribute. The time-to-live attribute logic is not covered by tests. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
| break; | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reminder: Add tests for provenance handling.
The provenance handling logic is not covered by tests.
Do you want me to generate the unit testing code or open a GitHub issue to track this task?
Tools
GitHub Check: codecov/patch