Skip to content

Commit

Permalink
[2.x] Allows persisting database sessions between queue jobs (#97)
Browse files Browse the repository at this point in the history
* Allows to persist database connections on queue lambda

* Apply fixes from StyleCI

* Fixes comparision

* Update QueueHandler.php

* Update QueueHandler.php

Co-authored-by: Taylor Otwell <[email protected]>
Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
3 people authored Sep 30, 2021
1 parent 1dbee6c commit 102d032
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Console/Commands/WritesQueueEventMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function listenForEvents()
* Write the status output for the queue worker.
*
* @param \Illuminate\Contracts\Queue\Job $job
* @param string $status
* @param string $status
* @return void
*/
protected function writeOutput(Job $job, $status)
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Fpm/FpmRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected static function getUriAndQueryString(array $event)
/**
* Get the query string from the event.
*
* @param array $event
* @param array $event
* @return string
*/
protected static function getQueryString(array $event)
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Handlers/CliHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CliHandler implements LambdaEventHandler
/**
* Handle an incoming Lambda event.
*
* @param array $event
* @param array $event
* @param \Laravel\Vapor\Contracts\LambdaResponse
* @return ArrayLambdaResponse
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Handlers/FpmHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class FpmHandler implements LambdaEventHandler
* Handle an incoming Lambda event.
*
* @param array $event
* @return \Laravel\Vapor\Contracts\LambdaResponse
* @return \Laravel\Vapor\Contracts\LambdaResponse
*/
public function handle(array $event)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Runtime/Handlers/QueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function handle(array $event)
*/
protected function terminate()
{
if (static::$app->resolved('db')) {
if (static::$app->resolved('db') && ($_ENV['VAPOR_QUEUE_DATABASE_SESSION_PERSIST'] ?? false) !== 'true') {
collect(static::$app->make('db')->getConnections())->each->disconnect();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/VaporJobTimedOutException.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class VaporJobTimedOutException extends Exception
/**
* Create a new exception instance.
*
* @param string $name
* @param Throwable|null $previous
* @param string $name
* @param Throwable|null $previous
*/
public function __construct($name, Throwable $previous = null)
{
Expand Down

0 comments on commit 102d032

Please sign in to comment.