-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from qpautrat/handle_serialize_publisher
feat: Chose which serializing strategy by configuration.
- Loading branch information
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Evaneos\BurrowBundle; | ||
|
||
use Burrow\Driver; | ||
use Burrow\Publisher\AsyncPublisher; | ||
use Burrow\Publisher\SerializingPublisher; | ||
use Burrow\Serializer\JsonSerializer; | ||
use Burrow\Serializer\PhpSerializer; | ||
|
||
class PublisherFactory | ||
{ | ||
const SERIALIZING_STRATEGY_NONE = 'none'; | ||
const SERIALIZING_STRATEGY_SERIALIZE = 'serialize'; | ||
const SERIALIZING_STRATEGY_JSON = 'json'; | ||
const DEFAULT_SERIALIZING_STRATEGY = self::SERIALIZING_STRATEGY_JSON; | ||
|
||
public static $SERIALIZING_STRATEGIES = [self::SERIALIZING_STRATEGY_NONE, self::SERIALIZING_STRATEGY_SERIALIZE, self::SERIALIZING_STRATEGY_JSON]; | ||
|
||
/** | ||
* @param Driver $driver | ||
* @param string $exchangeName | ||
* @param string $serializingStrategy | ||
* @return AsyncPublisher|SerializingPublisher | ||
*/ | ||
public static function buildAsync(Driver $driver, $exchangeName, $serializingStrategy) | ||
{ | ||
$publisher = new AsyncPublisher($driver, $exchangeName); | ||
|
||
if (self::SERIALIZING_STRATEGY_NONE === $serializingStrategy) { | ||
return $publisher; | ||
} elseif (self::SERIALIZING_STRATEGY_JSON === $serializingStrategy) { | ||
return new SerializingPublisher($publisher, new JsonSerializer()); | ||
} else { | ||
return new SerializingPublisher($publisher, new PhpSerializer()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ public function consume($message, array $headers = []) | |
{ | ||
// Do nothing | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ evaneos_burrow: | |
|
||
services: | ||
some_consumer: | ||
class: Tests\SomeConsumer | ||
class: Tests\SomeConsumer |