Skip to content

Commit

Permalink
code clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Mar 7, 2021
1 parent ad556ee commit b008ded
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
4 changes: 1 addition & 3 deletions src/ConnectionRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Config\Repository;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Contracts\Container\Container;

trait ConnectionRetrieval
{
Expand All @@ -17,9 +16,8 @@ trait ConnectionRetrieval
*/
protected function getConfig($name)
{
$container = $this->container ?? app()->make(Container::class);
if ($name) {
return $container->make(Repository::class)->get("queue.connections.{$name}");
return $this->container->make(Repository::class)->get("queue.connections.{$name}");
}

return ['driver' => 'null'];
Expand Down
9 changes: 7 additions & 2 deletions src/Dispatcher/AppEngineDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ public function __construct(Client $client, RequestGenerator $generator, string
* @param string $queue
* @throws \Google\ApiCore\ApiException
*/
public function dispatch(string $name, string $connection, string $payload, ?int $scheduledAt = null, string $queue = 'default') : void
{
public function dispatch(
string $name,
string $connection,
string $payload,
?int $scheduledAt = null,
string $queue = 'default'
) : void {
$httpRequest = $this->generator->forAppEngine($payload, $connection);

// Create a Cloud Task object.
Expand Down
14 changes: 7 additions & 7 deletions src/Dispatcher/HttpDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ class HttpDispatcher implements Dispatcher
* @var string
*/
private $locationId;

/**
* @var string
*/
private $serviceEmail;
/**
* @var RequestGenerator
*/
Expand Down Expand Up @@ -60,8 +55,13 @@ public function __construct(
* @param string $queue
* @throws \Google\ApiCore\ApiException
*/
public function dispatch(string $name, string $connection, string $payload, ?int $scheduledAt = null, string $queue = 'default'): void
{
public function dispatch(
string $name,
string $connection,
string $payload,
?int $scheduledAt = null,
string $queue = 'default'
) : void {
$httpRequest = $this->generator->forHttpHandler($payload, $connection);

if ($this->authenticator) {
Expand Down
8 changes: 7 additions & 1 deletion src/RequestGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Google\Cloud\Tasks\V2beta3\AppEngineHttpRequest;
use Google\Cloud\Tasks\V2beta3\HttpMethod;
use Google\Cloud\Tasks\V2beta3\HttpRequest;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Routing\UrlGenerator;
use Illuminate\Http\Request;

Expand All @@ -20,11 +21,16 @@ class RequestGenerator
* @var Request
*/
private $request;
/**
* @var Container
*/
private $container;

public function __construct(UrlGenerator $generator, Request $request)
public function __construct(UrlGenerator $generator, Request $request, Container $container)
{
$this->generator = $generator;
$this->request = $request;
$this->container = $container;
}

public function forAppEngine(string $payload, string $connection) : AppEngineHttpRequest
Expand Down
2 changes: 0 additions & 2 deletions tests/AppEngineJobProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,6 @@ public function getEnvironmentSetUp($app)
$app['config']->set('queue', require __DIR__ . '/../config/queue.php');
$app['config']->set('queue.connections.app_engine_tasks.project_id', 'test');
$app['config']->set('queue.connections.app_engine_tasks.location', 'europe-west1');
$app['config']->set('queue.connections.app_engine_tasks.project_id', 'test');
$app['config']->set('queue.connections.app_engine_tasks.location', 'europe-west1');

$app['config']->set('queue.failed.database', 'sqlite');

Expand Down
2 changes: 0 additions & 2 deletions tests/HttpTasksJobProcessingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ public function getEnvironmentSetUp($app)
$app['config']->set('queue', require __DIR__ . '/../config/queue.php');
$app['config']->set('queue.connections.http_cloud_tasks.project_id', 'test');
$app['config']->set('queue.connections.http_cloud_tasks.location', 'europe-west1');
$app['config']->set('queue.connections.app_engine_tasks.project_id', 'test');
$app['config']->set('queue.connections.app_engine_tasks.location', 'europe-west1');

$app['config']->set('queue.failed.database', 'sqlite');

Expand Down

0 comments on commit b008ded

Please sign in to comment.