looplab / eventhorizon

Event Sourcing for Go!
Apache License 2.0
1.57k stars 196 forks source link

Add custom collection names #407

Closed totemcaf closed 1 year ago

totemcaf commented 1 year ago

Description

Let use a custom name for Outbox and Snapshots collections.

Affected Components

Related Issues

None

Solution and Design

This is a replication of the available functionality to set event and streams collection names.

Added an Option to set the custom name:

The WithSnapshotCollectionName is added to kepp compatibility with exitent WithtCollectionName (and because I want to review if Snapshot should be part of this EventStore or should be another store).

Steps to test and verify

  1. Create an event store with custom name: NewEventStore(url, db, WithSnapshotCollectionName("foo"))

  2. Check in database the collection created is foo

  3. Create an outbox with custom name: NewOutbox(url, db, WithCollectionName("foo-outbox"))

  4. Check in database the collection created is foo-outbox

coveralls commented 1 year ago

Coverage Status

coverage: 67.237% (-0.4%) from 67.599% when pulling 337e2a331d516e54cfa4c78026be37f52ab9c1f7 on AltScore:feature/let-set-collection-names into 599169c1c4a89dc57954d5b871cd482b4c4ad02c on looplab:main.

totemcaf commented 1 year ago

@maxekman I added an additional check for spaces.

totemcaf commented 1 year ago

@maxekman fill free to merge

maxekman commented 1 year ago

Thanks!