Skip to content

Commit

Permalink
Merge pull request #1685 from brefphp/revert-1668-lambda-context-func…
Browse files Browse the repository at this point in the history
…tion

Revert "Expose the Lambda context in `LAMBDA_INVOCATION_CONTEXT` in the function runtime"
  • Loading branch information
mnapoli authored Nov 8, 2023
2 parents 378a63a + 3ed275a commit c048947
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions src/FunctionRuntime/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Bref\FunctionRuntime;

use Bref\Bref;
use Bref\Context\Context;
use Bref\LazySecretsLoader;
use Bref\Runtime\LambdaRuntime;
use Throwable;
Expand Down Expand Up @@ -35,17 +34,7 @@ public static function run(): void
if (++$loops > $loopMax) {
exit(0);
}

$success = $lambdaRuntime->processNextEvent(function ($event, Context $context) use ($handler) {
// Expose the context in an environment variable
// Used for example to retrieve the context in Laravel Queues jobs
$jsonContext = json_encode($context, JSON_THROW_ON_ERROR);
$_SERVER['LAMBDA_INVOCATION_CONTEXT'] = $_ENV['LAMBDA_INVOCATION_CONTEXT'] = $jsonContext;
putenv("LAMBDA_INVOCATION_CONTEXT=$jsonContext");

return $handler($event, $context);
});

$success = $lambdaRuntime->processNextEvent($handler);
// In case the execution failed, we force starting a new process regardless of BREF_LOOP_MAX
// Why: an exception could have left the application in a non-clean state, this is preventive
if (! $success) {
Expand Down

0 comments on commit c048947

Please sign in to comment.