OrleansContrib / Orleans.Providers.MongoDB

A MongoDb implementation of the Orleans Providers: Membership, Storage and Reminders.
MIT License
100 stars 43 forks source link

Feat/custom collection configuration #128

Closed dpavicic closed 11 months ago

dpavicic commented 11 months ago

This minor feature enhancement introduces an additional Action in the MongoDBGrainStorageOptions, which invokes the delegate in the MongoGrainStorageCollection's SetupCollection method.

This change facilitates additional configuration of MongoDB collections during the storage setup process. I've provided an exact example of this feature's application in the updated README (an example of how to add extra indexes). Check it out at: ### Configuring a MongoDB Collection section.

In my personal testing, I found this feature extremely useful as it promotes a hybrid approach. It enables us to leverage the strengths of Orleans while also allowing traditional queries over the grain collections in scenarios where Orleans may not be sufficient.

Cheers, DInko

SebastianStehle commented 11 months ago

I would refactor the existing CollectionConfigurator and make a async factory method, where you can change the settings AND add new indexes.

dpavicic commented 11 months ago

Yep, that would be a better solution, but I didn't want to break compatibility with the existing API.

I see the CollectionConfigurator is just an Action passing regular MongoCollectionSettings of the driver. public Action<MongoCollectionSettings> CollectionConfigurator { get; set; }

If this is changed, it would be a breaking change for a certain amount of people. Or did you mean to expand the Action with additional parameters to include, for example, something like Func<IMongoCollection<BsonDocument>, Task>

Can you please describe more about what you have in mind? Maybe I can help.