-
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.
Merge pull request #1 from arquivei/atualizacao_skeleton_php8_laravel8
Atualizacao versao Laravel e PHP
- Loading branch information
Showing
49 changed files
with
1,304 additions
and
382 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Adapters\Event; | ||
|
||
use Arquivei\Events\Sender\Exceptions\EmptyExportersException; | ||
use Arquivei\Events\Sender\Exceptions\PusherException; | ||
use Arquivei\Events\Sender\Factories\LatestSchemaFactory; | ||
use Arquivei\Events\Sender\Pusher; | ||
use Arquivei\Events\Sender\Schemas\BaseSchema; | ||
use Core\Dependencies\Event\Event; | ||
use Core\Dependencies\Event\EventSenderInterface; | ||
|
||
class EventSenderAdapter implements EventSenderInterface | ||
{ | ||
private Pusher $pusher; | ||
private string $stream; | ||
|
||
public function __construct( | ||
EventSenderConfig $config, | ||
private LatestSchemaFactory $latestSchemaFactory, | ||
) { | ||
$this->pusher = $config->getPusher(); | ||
$this->stream = $config->getEventsStream(); | ||
} | ||
|
||
/** | ||
* @throws EmptyExportersException|PusherException | ||
*/ | ||
public function push(Event $event, string $stream = null, string $key = null): void | ||
{ | ||
if (is_null($stream)) { | ||
$stream = $this->stream; | ||
} | ||
$schema = $this->buildSchema($event); | ||
$this->pusher->push($schema, $stream, $key); | ||
} | ||
|
||
private function buildSchema(Event $event): BaseSchema | ||
{ | ||
return $this->latestSchemaFactory->createFromParameters( | ||
$event->getSource(), | ||
$event->getType(), | ||
$event->getDataVersion(), | ||
$event->getData(), | ||
); | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Adapters\Event; | ||
|
||
use Arquivei\Events\Sender\Pusher; | ||
|
||
class EventSenderConfig | ||
{ | ||
public function __construct( | ||
private Pusher $pusher, | ||
private string $eventsStream, | ||
) { | ||
} | ||
|
||
public function getPusher(): Pusher | ||
{ | ||
return $this->pusher; | ||
} | ||
|
||
public function getEventsStream(): string | ||
{ | ||
return $this->eventsStream; | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace App\Adapters\Event; | ||
|
||
use Core\Dependencies\Event\Event; | ||
|
||
class ExampleEvent implements Event | ||
{ | ||
private string $source = 'example-app'; | ||
private string $type = 'example-event'; | ||
|
||
public function __construct( | ||
private array $data, | ||
private int $dataVersion | ||
) { | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function getSource(): string | ||
{ | ||
return $this->source; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function getDataVersion(): int | ||
{ | ||
return $this->dataVersion; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Adapters\Kafka; | ||
|
||
class KafkaConfig | ||
{ | ||
public function __construct( | ||
private string $brokers, | ||
private string $saslUsername, | ||
private string $saslPassword, | ||
private string $saslMechanism, | ||
private string $securityProtocol, | ||
private string $eventsStream, | ||
) { | ||
} | ||
|
||
public function getBrokers(): string | ||
{ | ||
return $this->brokers; | ||
} | ||
|
||
public function getSaslUsername(): string | ||
{ | ||
return $this->saslUsername; | ||
} | ||
|
||
public function getSaslPassword(): string | ||
{ | ||
return $this->saslPassword; | ||
} | ||
|
||
public function getSaslMechanism(): string | ||
{ | ||
return $this->saslMechanism; | ||
} | ||
|
||
public function getSecurityProtocol(): string | ||
{ | ||
return $this->securityProtocol; | ||
} | ||
|
||
public function getEventsStream(): string | ||
{ | ||
return $this->eventsStream; | ||
} | ||
} |
Oops, something went wrong.