HomeDevCentral

Broker factory

Description

Broker factory

Summary:
Applications consuming our library wants generally to declare the broker
in the configuration, including its type.

We provide a BrokerFactory::make method to instanciate a broker with
an array like this:

[
    "driver" => "amqp",
    "host" => "rabbit.domain.tld",
    "port" => "5672",
    "username" => "lorem",
    "password" => "ipsum",
    "vhost" => "dolor",
]

The file drivers.php contains the map between the drivers names
and the classses to load.

Each broker class implements a makeFromConfig ($params) static method
to build an object from such array.

The BrokerFactory::make method gets from drivers.php the correct class,
then calls makeFromConfig and returns the result.

Test Plan: Run tests

Reviewers: dereckson

Differential Revision: http://devcentral.nasqueron.org/D225

Details

Auditors
dereckson
Provenance
derecksonAuthored on
Differential Revision
D225: Broker factory
Parents
rKBROKERbce24f7cd707: AMQPBroker::connect port parameter is now an integer
Branches
Unknown
Tags
Unknown

Event Timeline

dereckson added inline comments.
/src/Broker.php
8

ErrorException: Static function Keruald\Broker\Broker::makeFromConfig() should not be abstract

dereckson marked an inline comment as done.

Fixed in D227.

dereckson added inline comments.
/src/BlackholeBroker.php
28

Nasqueron\Notifications\Tests\Providers\BrokerServiceProviderTest::testType
ErrorException: Undefined index: omnipotence

/workspace/3rdparty/keruald/broker/src/BlackholeBroker.php:28
/workspace/3rdparty/keruald/broker/src/BrokerFactory.php:40
/workspace/notifications/app/Providers/BrokerServiceProvider.php:31

dereckson marked an inline comment as done.

Fixed in D233.