Skip to content

Commit

Permalink
Allow dynamic parameters in DSN
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMikes authored and f3l1x committed Jul 15, 2023
1 parent 3a098e0 commit 99e5d92
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DI/MessengerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function getConfigSchema(): Schema
),
'transport' => Expect::arrayOf(
Expect::structure([
'dsn' => Expect::string()->required(),
'dsn' => Expect::string()->required()->dynamic(),
'options' => Expect::array(),
'serializer' => $expectService,
'failureTransport' => Expect::string(),
Expand Down
19 changes: 19 additions & 0 deletions tests/Cases/DI/MessengerExtension.transport.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,22 @@ Toolkit::test(function (): void {

Assert::count(1, $container->findByTag(MessengerExtension::FAILURE_TRANSPORT_TAG));
});

// Dynamic parameters
Toolkit::test(function (): void {
$container = Container::of()
->withDefaults()
->withDynamicParameters(['sync_dsn' => 'sync://'])
->withCompiler(function (Compiler $compiler): void {
$compiler->addConfig(Helpers::neon(<<<'NEON'
messenger:
transport:
sync:
dsn: %sync_dsn%
NEON
));
})
->build();

Assert::type(SyncTransport::class, $container->getByName('messenger.transport.sync'));
});

0 comments on commit 99e5d92

Please sign in to comment.