Compare commits
2 Commits
main
...
8320fb4a84
| Author | SHA1 | Date | |
|---|---|---|---|
| 8320fb4a84 | |||
| c481c961fb |
@@ -3,7 +3,7 @@
|
||||
"description": "A laravel package for events emitting between services using RabbitMQ as message broker.",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"version": "1.1.0",
|
||||
"version": "1.2.0",
|
||||
"keywords": [
|
||||
"laravel", "rabbitmq", "event", "emit", "microservice",
|
||||
"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;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
interface Broadcast extends JsonSerializable
|
||||
interface Broadcast
|
||||
{
|
||||
public function getConnection(): string;
|
||||
public function getQueue(): string;
|
||||
|
||||
@@ -11,16 +11,16 @@ use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
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(
|
||||
json_encode($data->jsonSerialize())
|
||||
json_encode($event->jsonSerialize())
|
||||
);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(
|
||||
'Data should be an instance of BroadcastEvent'
|
||||
'Event should be an instance of JsonSerializable'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user