-
Notifications
You must be signed in to change notification settings - Fork 3
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
Sam: Projection read model copies to MongoDB #125
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on projection read model classes signifying that they should be stored in a MongoDB copy store
…on name and an extension method on IMongoDatabase to get the collection for a projection read model type
…art on the resolving logic for the MongoDB copy definition
…r to evaluate it as a MemberExpression
…ection read model
… ignores extra elements
…vertToAttributesBuilder
ConversionsFromMongoDBConvertToAttributesBuilder better
Mongodb copy attribute
Projections ioc
Co-authored-by: Jakob Høgenes <1014990+jakhog@users.noreply.github.com>
Co-authored-by: Jakob Høgenes <1014990+jakhog@users.noreply.github.com>
…T.SDK into conversions-from-classmap
Conversions from classmap
jakhog
changed the title
Projection secondary storage
Sam: Projection read model copies to MongoDB
Feb 9, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Introduces APIs to configure secondary storage for Projection read models for querying, as introduced in dolittle/Runtime#614 (requires Runtime v7.6.0). These changes makes it easy to query Projection read models by specifying that you want copies stored in MongoDB, and then use an
IMongoCollection<>
for that Projection as any other MongoDB collection. The Projection still operates normally and can be fetched from the Projection Store. Modifications of documents in the copied collections will affect the original Projection processing, but should be avoided as it could cause unexpected behaviour. The collections are automatically created and dropped as needed by the Runtime when Projections are created or changed.There is currently no mechanism for detecting multiple projections copied to the same collection, so be aware of possible strange behaviour if you have multiple Projections with the same name.
Added
[CopyToMongoDB(...)]
attribute that enables read model copies for a Projection class to MongoDB. The default collection name is the same as the class name. The attribute accepts an argument to override the collection name.[ConvertToMongoDB(conversion)]
attribute to specify a BSON conversion to apply when copying the Projection read model to a MongoDB collection. By default the same conversions as the MongoDB driver uses is applied..CopyToMongoDB(...)
method on the Projection builder for enabling read model copies for Projections created using the builder API. This method accepts a callback that you can use to set the collection name and conversions for the read model copies. You can also disable default MongoDB driver conversions.IMongoDatabase
in the tenant scoped DI containers.IMongoCollection<TReadModel>
in the tenant scoped DI containers for each Projection.IMongoDatabase.GetCollection<TReadModel>(settings = null)
to get a collection using the name of the read model or the collection specified in the[CopyToMongoDB(collection)]
attribute.Changed
IgnoreExtraElements
for all types in the MongoDB driver when the Dolittle Client is used. This is not default behaviour for the MongoDB driver, but when using MongoDB for read model storage, this should not affect the application adversely.