kmongo
kmongo copied to clipboard
Jackson serializaition module uses global mutable variables
It is known global mutable variables are the root of all evil.
Also, my project uses two different CodecRegistries, so it basically uses different serialization configurations, and the fact that the bson mapper used by kmongo is global, ruins adoption for me. (https://github.com/Litote/kmongo/blob/master/kmongo-jackson-mapping/src/main/kotlin/org/litote/kmongo/util/KMongoConfiguration.kt) Can we make this a class, instead of an global object?
The issue is that KMongo provides stateless methods like .json or .bson with no relation with MongoClient instance.
So allowing to provide different configurations for a same java runtime would be error prone.
What is the use case for which you need to use two different CodecRegistries at the same time ?
Moving out of legacy mongo stuff. We cannot just change it all... So we want to give support with the old CodecRegistry, but in use a new CodecRegistry in the new collections
In java driver, CodecRegistry can be Collection scoped, Database scoped or Client scoped. It should be doable to pass a configuration for each of this class.
If you "legacy stuff" is not powered by KMongo, you have the option to set manually an old CodecRegistry.