Compare commits
2 Commits
ac735d8bf5
...
8320fb4a84
| Author | SHA1 | Date | |
|---|---|---|---|
| 8320fb4a84 | |||
| c481c961fb |
@@ -3,7 +3,7 @@
|
|||||||
"description": "A laravel package for events emitting between services using RabbitMQ as message broker.",
|
"description": "A laravel package for events emitting between services using RabbitMQ as message broker.",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "1.1.0",
|
"version": "1.2.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"laravel", "rabbitmq", "event", "emit", "microservice",
|
"laravel", "rabbitmq", "event", "emit", "microservice",
|
||||||
"pipeline", "data exchanging", "message", "broker", "php8",
|
"pipeline", "data exchanging", "message", "broker", "php8",
|
||||||
|
|||||||
501
composer.lock
generated
501
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -4,9 +4,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Diffhead\PHP\LaravelRabbitMQ\Event;
|
namespace Diffhead\PHP\LaravelRabbitMQ\Event;
|
||||||
|
|
||||||
use JsonSerializable;
|
interface Broadcast
|
||||||
|
|
||||||
interface Broadcast extends JsonSerializable
|
|
||||||
{
|
{
|
||||||
public function getConnection(): string;
|
public function getConnection(): string;
|
||||||
public function getQueue(): string;
|
public function getQueue(): string;
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ use PhpAmqpLib\Message\AMQPMessage;
|
|||||||
|
|
||||||
class Serializer implements SerializerInterface
|
class Serializer implements SerializerInterface
|
||||||
{
|
{
|
||||||
public function serialize(object $data): AMQPMessage
|
public function serialize(object $event): AMQPMessage
|
||||||
{
|
{
|
||||||
if ($data instanceof JsonSerializable) {
|
if ($event instanceof JsonSerializable) {
|
||||||
return new AMQPMessage(
|
return new AMQPMessage(
|
||||||
json_encode($data->jsonSerialize())
|
json_encode($event->jsonSerialize())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
'Data should be an instance of BroadcastEvent'
|
'Event should be an instance of JsonSerializable'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user