Skip to content

Commit d1c1d2c

Browse files
committed
Parameterize config to accept connection names.
- `TaskHandler` still needs to be updated. Might look for some input there.
1 parent 578ee7d commit d1c1d2c

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/CloudTasksQueue.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ public function later($delay, $job, $data = '', $queue = null)
5252
protected function pushToCloudTasks($queue, $payload, $delay = 0, $attempts = 0)
5353
{
5454
$queue = $this->getQueue($queue);
55-
$queueName = $this->client->queueName(Config::project(), Config::location(), $queue);
55+
$queueName = $this->client->queueName(Config::project($this->connectionName), Config::location($this->connectionName), $queue);
5656
$availableAt = $this->availableAt($delay);
5757

5858
$httpRequest = $this->createHttpRequest();
59-
$httpRequest->setUrl(Config::handler());
59+
$httpRequest->setUrl(Config::handler($this->connectionName));
6060
$httpRequest->setHttpMethod(HttpMethod::POST);
6161
$httpRequest->setBody($payload);
6262

6363
$task = $this->createTask();
6464
$task->setHttpRequest($httpRequest);
6565

6666
$token = new OidcToken;
67-
$token->setServiceAccountEmail(Config::serviceAccountEmail());
67+
$token->setServiceAccountEmail(Config::serviceAccountEmail($this->connectionName));
6868
$httpRequest->setOidcToken($token);
6969

7070
if ($availableAt > time()) {

src/Config.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@
66

77
class Config
88
{
9-
public static function credentials()
9+
public static function credentials($connection = 'cloudtasks')
1010
{
11-
return config('queue.connections.cloudtasks.credentials');
11+
return config("queue.connections.{$connection}.credentials");
1212
}
1313

14-
public static function project()
14+
public static function project($connection = 'cloudtasks')
1515
{
16-
return config('queue.connections.cloudtasks.project');
16+
return config("queue.connections.{$connection}.project");
1717
}
1818

19-
public static function location()
19+
public static function location($connection = 'cloudtasks')
2020
{
21-
return config('queue.connections.cloudtasks.location');
21+
return config("queue.connections.{$connection}.location");
2222
}
2323

24-
public static function handler()
24+
public static function handler($connection = 'cloudtasks')
2525
{
26-
return config('queue.connections.cloudtasks.handler');
26+
return config("queue.connections.{$connection}.handler");
2727
}
2828

29-
public static function serviceAccountEmail()
29+
public static function serviceAccountEmail($connection = 'cloudtasks')
3030
{
31-
return config('queue.connections.cloudtasks.service_account_email');
31+
return config("queue.connections.{$connection}.service_account_email");
3232
}
3333

3434
public static function validate(array $config)

0 commit comments

Comments
 (0)