Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Mongo data center aware ObjectId

This is just an idea on MongoDB ObjectId

If you want to split data on multiple shards using only the _id field

sh.enableSharding("demo");
sh.shardCollection("demo.foo", { _id : 1 } );
sh.addTagRange("demo.foo", { _id: MinKey }, { _id: ObjectId("640000000000000000000000") }, "DC1");
sh.addTagRange("demo.foo", { _id: ObjectId("640000000000000000000000") }, { _id: MaxKey }, "DC2");

When the app starts you have to set the right value for the data-center identifier to target data to desired data-center using only the _id field

DataCenterAwareIdGenerator.DataCenter = 200;

About

Mongo data center aware ObjectId

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages