New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom collection names #407
Add custom collection names #407
Conversation
Add custom collection name for Snapshots
@@ -140,6 +125,62 @@ func TestWithCollectionNamesIntegration(t *testing.T) { | |||
} | |||
} | |||
|
|||
func TestWithSnapshotCollectionNamesIntegration(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Table-based tests would be useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, feel free to do it, or it can be done as part of a larger test overhaul in the future (nothing planned though).
|
||
// providing empty snapshot collection names should result in an error | ||
_, err = NewEventStore(url, db, | ||
WithSnapshotCollectionName(""), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if " "
or similar is passed in? This could happen if the caller is dynamically forming the collection name and doesn't sufficiently check that it's not just pure whitespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, relates to your comment about trimming above. Feel free to add a test case for it, but I'll accept the PR without it too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice addition! Feel free to resolve what you want, I can merge when you are happy.
@maxekman I added an additional check for spaces. |
@maxekman fill free to merge |
Thanks! |
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
Create an event store with custom name:
NewEventStore(url, db, WithSnapshotCollectionName("foo"))
Check in database the collection created is
foo
Create an outbox with custom name:
NewOutbox(url, db, WithCollectionName("foo-outbox"))
Check in database the collection created is
foo-outbox