Skip to content

Commit 5738270

Browse files
committed
refactor: rename Context to InvocationContext
1 parent df55760 commit 5738270

27 files changed

Lines changed: 140 additions & 139 deletions

src/Lambda/Handler/Sqs/AbstractSqsHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Ymir\Runtime\Lambda\Handler\Sqs;
1515

1616
use Ymir\Runtime\Lambda\Handler\LambdaEventHandlerInterface;
17-
use Ymir\Runtime\Lambda\InvocationEvent\Context;
17+
use Ymir\Runtime\Lambda\InvocationEvent\InvocationContext;
1818
use Ymir\Runtime\Lambda\InvocationEvent\InvocationEventInterface;
1919
use Ymir\Runtime\Lambda\InvocationEvent\SqsEvent;
2020
use Ymir\Runtime\Lambda\InvocationEvent\SqsRecord;
@@ -83,5 +83,5 @@ public function handle(InvocationEventInterface $event): ResponseInterface
8383
/**
8484
* Process a SQS message record.
8585
*/
86-
abstract protected function processRecord(Context $context, SqsRecord $record): void;
86+
abstract protected function processRecord(InvocationContext $context, SqsRecord $record): void;
8787
}

src/Lambda/Handler/Sqs/LaravelSqsHandler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Ymir\Runtime\Lambda\Handler\Sqs;
1515

1616
use Symfony\Component\Process\Process;
17-
use Ymir\Runtime\Lambda\InvocationEvent\Context;
17+
use Ymir\Runtime\Lambda\InvocationEvent\InvocationContext;
1818
use Ymir\Runtime\Lambda\InvocationEvent\InvocationEventInterface;
1919
use Ymir\Runtime\Lambda\InvocationEvent\SqsRecord;
2020
use Ymir\Runtime\Logger;
@@ -51,7 +51,7 @@ public function canHandle(InvocationEventInterface $event): bool
5151
/**
5252
* {@inheritdoc}
5353
*/
54-
protected function processRecord(Context $context, SqsRecord $record): void
54+
protected function processRecord(InvocationContext $context, SqsRecord $record): void
5555
{
5656
$message = json_encode($record);
5757

@@ -86,7 +86,7 @@ protected function processRecord(Context $context, SqsRecord $record): void
8686
/**
8787
* Calculate the timeout for processing the SQS record.
8888
*/
89-
private function calculateTimeout(Context $context): int
89+
private function calculateTimeout(InvocationContext $context): int
9090
{
9191
$timeout = (int) ($_ENV['YMIR_QUEUE_TIMEOUT'] ?? $_ENV['QUEUE_TIMEOUT'] ?? 0);
9292
$remainingTime = (int) max(0, $context->getRemainingTimeInMs() / 1000 - 1);

src/Lambda/InvocationEvent/AbstractEvent.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@ abstract class AbstractEvent implements InvocationEventInterface
2121
/**
2222
* The Lambda invocation context.
2323
*
24-
* @var Context
24+
* @var InvocationContext
2525
*/
2626
private $context;
2727

2828
/**
2929
* Constructor.
3030
*/
31-
public function __construct(Context $context)
31+
public function __construct(InvocationContext $context)
3232
{
3333
$this->context = $context;
3434
}
3535

3636
/**
3737
* {@inheritdoc}
3838
*/
39-
public function getContext(): Context
39+
public function getContext(): InvocationContext
4040
{
4141
return $this->context;
4242
}

src/Lambda/InvocationEvent/ConsoleCommandEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ConsoleCommandEvent extends AbstractEvent
2828
/**
2929
* Constructor.
3030
*/
31-
public function __construct(Context $context, string $command)
31+
public function __construct(InvocationContext $context, string $command)
3232
{
3333
parent::__construct($context);
3434

src/Lambda/InvocationEvent/HttpRequestEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class HttpRequestEvent extends AbstractEvent
2828
/**
2929
* Constructor.
3030
*/
31-
public function __construct(Context $context, array $event = [])
31+
public function __construct(InvocationContext $context, array $event = [])
3232
{
3333
parent::__construct($context);
3434

src/Lambda/InvocationEvent/Context.php renamed to src/Lambda/InvocationEvent/InvocationContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* The Lambda invocation context.
2020
*/
21-
class Context implements \JsonSerializable
21+
class InvocationContext implements \JsonSerializable
2222
{
2323
/**
2424
* The deadline for the Lambda invocation in milliseconds.

src/Lambda/InvocationEvent/InvocationEventFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static function createFromApi($handle, Logger $logger): InvocationEventIn
6161
throw new RuntimeApiException('Unable to parse the Lambda runtime API response');
6262
}
6363

64-
$context = Context::fromHeaders($headers);
64+
$context = InvocationContext::fromHeaders($headers);
6565
$event = json_decode($body, true);
6666

6767
if (!is_array($event)) {
@@ -79,7 +79,7 @@ public static function createFromApi($handle, Logger $logger): InvocationEventIn
7979
/**
8080
* Creates a new invocation event object based on the given event information from the Lambda runtime API.
8181
*/
82-
public static function createFromInvocationEvent(Context $context, array $event): InvocationEventInterface
82+
public static function createFromInvocationEvent(InvocationContext $context, array $event): InvocationEventInterface
8383
{
8484
$invocationEvent = null;
8585

src/Lambda/InvocationEvent/InvocationEventInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ interface InvocationEventInterface
2121
/**
2222
* Get the context of the Lambda invocation.
2323
*/
24-
public function getContext(): Context;
24+
public function getContext(): InvocationContext;
2525
}

src/Lambda/InvocationEvent/PhpConsoleCommandEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class PhpConsoleCommandEvent extends ConsoleCommandEvent
2121
/**
2222
* Constructor.
2323
*/
24-
public function __construct(Context $context, string $command)
24+
public function __construct(InvocationContext $context, string $command)
2525
{
2626
parent::__construct($context, sprintf('/opt/bin/php %s', $command));
2727
}

src/Lambda/InvocationEvent/SqsEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SqsEvent extends AbstractEvent
3232
/**
3333
* Constructor.
3434
*/
35-
public function __construct(Context $context, array $event = [])
35+
public function __construct(InvocationContext $context, array $event = [])
3636
{
3737
parent::__construct($context);
3838

0 commit comments

Comments
 (0)