surgio/eloquent-message-repository
MessageRepository, decoupling event storage from EventSauce’s default implementations (e.g., filesystem, Redis). This aligns with Laravel’s philosophy of leveraging existing tooling (Eloquent) for domain concerns.AggregateRootRepository and message serialization (e.g., ConstructingMessageSerializer). Teams new to EventSauce may face a steep learning curve.aggregate_id, event_type, payload). Misalignment could lead to data corruption or query inefficiencies.Why Eloquent?
Event Structure
Concurrency & Consistency
Testing & Observability
EventSauce\EventSourcing\EventStore).Future-Proofing
Assess Current Event Storage:
Schema Design:
messages table (e.g., add indexes for aggregate_id + version).Schema::create('messages', function (Blueprint $table) {
$table->id();
$table->string('aggregate_id');
$table->string('event_type');
$table->json('payload'); // or text for large events
$table->unsignedInteger('version');
$table->timestamps();
$table->index(['aggregate_id', 'version']);
});
Bind the Repository:
$this->app->bind(
EventSauce\EventSourcing\MessageRepository::class,
fn() => new EloquentMessageRepository(new ConstructingMessageSerializer())
);
Incremental Rollout:
SELECT * FROM messages WHERE aggregate_id = ? ORDER BY version).MessageSerializer (e.g., ConstructingMessageSerializer). Ensure payloads are serializable to JSON/array.Prerequisites:
composer require eventsauce/eventsauce eventsauce/constructing-message-serializer
Core Integration:
php artisan migrate.config/eventsauce.php or a service provider.Testing:
AggregateRootRepository with the new repository.Production Rollout:
EventStore features (e.g., replay, projections).MessageRepository interface.retrieved, saved).aggregate_id, version, and event_type.DB::transaction).How can I help you explore Laravel packages today?