ARKADIUSZ KONDAS
Data Scientist @ Buddy.Works
Zend Certified Engineer
Software Architect, Event Stormer, Event Modeler, Clean Coder, Blogger, Ultrarunner
@ ArkadiuszKondas
arkadiuszkondas.com
Zend Certified Architect
CQRS
https://twitter.com/adymitruk/status/1172414109029031941
php:
build: ./BookingPhp
volumes:
- "./eventStore:/events"
labels:
- "traefik.enable=true"
- "traefik.backend=php"
- "traefik.docker.network=web"
- "traefik.frontend.rule=Path:/room-inventory,/create_room,/change_type_price,/room-types"
- "traefik.port=80"
# - "com.centurylinklabs.watchtower.enable=true"
networks:
- web
dotnet:
image: eventmodeling/dotnet:latest
links:
- eventstore
volumes:
- "./eventStore:/App/DATA"
labels:
- "traefik.enable=true"
- "traefik.backend=dotnet"
- "traefik.docker.network=web"
- "traefik.frontend.rule=PathPrefix:/Room/,/room/"
- "traefik.port=8080"
- "com.centurylinklabs.watchtower.enable=true"
environment:
- "WORKSHOP_EVENTSTORE_PASSWORD=${EVENTSTORE_PASSWORD}"
networks:
- web
java:
image: eventmodeling/java:latest
volumes:
- "./eventStore:/tmp/events"
labels:
- "traefik.enable=true"
- "traefik.backend=java"
- "traefik.docker.network=web"
- "traefik.frontend.rule=PathPrefix:/api/booking/book-room,/api/payment/details/"
- "traefik.port=12378"
- "com.centurylinklabs.watchtower.enable=true"
networks:
<?php
namespace App\EventStore;
interface EventStore
{
public function append(Event $event, string $suffix): void;
public function getEvents(): array;
}
<?php
namespace App\EventStore;
class JsonFileSystemEventStore implements EventStore
{
/** @var string */
private $directory;
public function __construct(string $directory)
{
$this->directory = $directory;
if(!is_dir($this->directory)) {
throw new \InvalidArgumentException("[$directory] is NOT a directory");
}
}
public function append(Event $event, string $suffix): void
{
$result = file_put_contents(
sprintf(
'%s/%s-%s-%s.json',
$this->directory,
$event->getDateTime()->format('U') * 1000,
$event->getType(),
$suffix
),
json_encode($event->toJson())
);
if($result === false) {
throw new \Exception("Failed to append event");
}
}
@ ArkadiuszKondas
https://slides.com/arkadiuszkondas
https://github.com/akondas