Mongo DB Application Sharding allows you to shard your Mongo DB cluster from your application using different strategies. This project is inspired by Apache's shardingsphere which enables the users to shard the relational databases through the application.
Application Sharding Strategies supported by the library
- Collection Sharding Strategy
- Database Sharding Strategy
- Composite Sharding Strategy
To use this library in your project, just add the package sharding-spring
as a dependency to your project.
<!-- sharding-spring -->
<dependency>
<groupId>com.alpha.mongodb</groupId>
<artifactId>sharding-spring</artifactId>
<version>${mongodb.sharding.version}</version>
</dependency>
<!-- sharding-driver -->
<dependency>
<groupId>com.alpha.mongodb</groupId>
<artifactId>sharding-driver</artifactId>
<version>${mongodb.sharding.version}</version>
</dependency>
To see a sample usage of different Sharding Strategies, visit the documentation here.
- Supports 3 different sharding strategies for Spring / Spring Boot projects by extending MongoTemplate.
- Supports Reactive Mongo Templates (for all the sharding strategies)
- Sharding support for Mongo Clients (without the need of spring dependencies). This supports both executable and reactive Mongo Clients.
- Hint Resolution through ThreadLocal and callback based mechanism.
- Automatic Hint Resolution Callback discovery for Spring Beans using ApplicationContext
- Custom configuration available for Sharding, validation of shards etc.
- Tested using Spring's Mongo Template and Repository
This project is in its budding stage. But I do see a lot of features that can be added.
- More customization to Sharding options to allow dynamic shards, custom validations etc.
- Support non-sharded collections within a sharded database.
- Support to query from all the shards when the library is unable to route the query to a particular shard.
- Configuring Sharding from property files without writing any Java Code
- Support Aggregation queries
- And so much more...!