-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split event message from builder (#34)
Split event message from builder
- Loading branch information
Showing
25 changed files
with
219 additions
and
209 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
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,27 @@ | ||
<?php | ||
|
||
namespace Softonic\TransactionalEventPublisher\Builders; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Support\Carbon; | ||
use Softonic\TransactionalEventPublisher\Interfaces\EventMessageBuilderInterface; | ||
use Softonic\TransactionalEventPublisher\Interfaces\EventMessageInterface; | ||
use Softonic\TransactionalEventPublisher\ValueObjects\EventMessage; | ||
|
||
class EventMessageBuilder implements EventMessageBuilderInterface | ||
{ | ||
|
||
public function build(Model $model, string $eventType): EventMessageInterface | ||
{ | ||
$modelName = class_basename($model); | ||
|
||
return new EventMessage( | ||
service: config('transactional-event-publisher.service'), | ||
eventType: $eventType, | ||
modelName: $modelName, | ||
eventName: $modelName . ucfirst($eventType), | ||
payload: $model->toArray(), | ||
createdAt: Carbon::now()->toDateTimeString(), | ||
); | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,10 @@ | ||
<?php | ||
|
||
namespace Softonic\TransactionalEventPublisher\Interfaces; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
interface EventMessageBuilderInterface | ||
{ | ||
public function build(Model $model, string $eventType): EventMessageInterface; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
namespace Softonic\TransactionalEventPublisher\Interfaces; | ||
|
||
use JsonSerializable; | ||
|
||
interface EventMessageInterface extends JsonSerializable | ||
{ | ||
/** | ||
* Returns the message in an array format. | ||
*/ | ||
public function toArray(): array; | ||
} |
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,11 @@ | ||
<?php | ||
|
||
namespace Softonic\TransactionalEventPublisher\Interfaces; | ||
|
||
interface EventStoreMiddlewareInterface | ||
{ | ||
/** | ||
* Stores in the message-oriented middleware. | ||
*/ | ||
public function store(EventMessageInterface ...$messages): bool; | ||
} |
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
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
Oops, something went wrong.