Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
add support for configuring auto topic & subscription creation for th…
Browse files Browse the repository at this point in the history
…e php-pubsub-google-cloud adapter
  • Loading branch information
matthewgoslett committed Sep 15, 2016
1 parent d3fb075 commit 32952eb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
'driver' => 'gcloud',
'project_id' => null,
'key_file' => null,
'auto_create_topics' => true,
'auto_create_subscriptions' => true,
],

],
Expand Down
5 changes: 4 additions & 1 deletion src/PubSubConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ protected function makeGoogleCloudAdapter(array $config)
];
$client = $this->container->make('pubsub.gcloud.pub_sub_client', ['config' => $clientConfig]);

return new GoogleCloudPubSubAdapter($client);
$autoCreateTopics = array_get($config, 'auto_create_topics', true);
$autoCreateSubscriptions = array_get($config, 'auto_create_subscriptions', true);

return new GoogleCloudPubSubAdapter($client, $autoCreateTopics, $autoCreateSubscriptions);
}
}
6 changes: 6 additions & 0 deletions tests/PubSubConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ public function testMakeGoogleCloudAdapter()
];
$adapter = $factory->make('gcloud', $config);
$this->assertInstanceOf(GoogleCloudPubSubAdapter::class, $adapter);

$config['auto_create_topics'] = false;
$adapter = $factory->make('gcloud', $config); /** @var GoogleCloudPubSubAdapter $adapter */
$this->assertInstanceOf(GoogleCloudPubSubAdapter::class, $adapter);
$this->assertFalse($adapter->areTopicsAutoCreated());
$this->assertTrue($adapter->areSubscriptionsAutoCreated());
}

public function testMakeInvalidAdapterThrowsInvalidArgumentException()
Expand Down

0 comments on commit 32952eb

Please sign in to comment.