-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Added explicit storage type selection for MongoDB Event Store #151
Conversation
Exposed strongly typed storage options for MongoDB Event Store. Added possibility to provide custom collection and database resolution. Moved storage related code to a dedicated file, as it got a bit too crowdy in the MongoDBEventStore implementation.
@alex-laycalvert, I need to add tests for the collection resolution-related code, but could you check if this works for you? I was going back and forth on whether we should make the storage setting explicit or not. On the one hand, it's an important decision; on the other, many new users probably won't know which one is better, so we'll still need to document it. So, at this point, I decided to make the default choice implicit to collection per stream type to encourage people to use the default. |
45bc34d
to
af0f285
Compare
@alex-laycalvert, I added unit and e2e tests for storage resolution, it's fully ready for code review 👍 |
af0f285
to
021db39
Compare
We have a dedicated set of e2e tests for projections. No need to keep the noise in the other places.
src/packages/emmett-mongodb/src/eventStore/mongoDBEventStore.connection.e2e.spec.ts
Show resolved
Hide resolved
src/packages/emmett-mongodb/src/eventStore/mongoDBEventStore.connection.e2e.spec.ts
Show resolved
Hide resolved
src/packages/emmett-mongodb/src/eventStore/mongoDBEventStore.storage.e2e.spec.ts
Show resolved
Hide resolved
src/packages/emmett-mongodb/src/eventStore/storage/mongoDBEventStoreStorage.unit.spec.ts
Show resolved
Hide resolved
MongoClient, | ||
} from 'mongodb'; | ||
|
||
export const getDummyCollection = <TSchema extends Document = Document>( |
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.
COMMENT: Intention behind this dummy collection is to be used in the structure tests, not to act as an in-memory collection.
Added also comments for Mongo dummy mocks
aaf7242
to
dacbef5
Compare
… instead of having it in each test
38cda85
to
63a684e
Compare
… able to reuse it
63a684e
to
c991d64
Compare
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.
I like it!
I think this should be enough for a while as far as how far the store options can be customized. |
@alex-laycalvert, thanks for checking it out!
Yes, I think that we now have good foundations of the MongoDB storage layout 👍 I'll release it next week, and also write an article about it 🙂 |
Exposed strongly typed storage options for MongoDB Event Store. Now they can be explicitly selected and mutually exclusive:
COLLECTION_PER_STREAM_TYPE
- default option, where each stream type has a dedicated storage. As we're keeping inline projections in the same document as the stream, then that gives a better option for custom indexing and better storage usage.SINGLE_COLLECTION
can be either custom or default toemt:streams
. This can be a fair choice if you don't have a large number of streams or you don't need customisation per stream type.CUSTOM
- you can define your own collection resolution based on the stream type. It might be that you need to route databases per tenant or handle some other more advanced stuff, so this is the choice for you.Added the possibility of providing custom collection and database resolution.
Moved storage-related code to a dedicated file, as it got a bit too crowded in the MongoDBEventStore implementation.
Fixes #142