![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@monti-apm/mongo-sharded-cluster
Advanced tools
Shard MongoDB in the app layer and build a MongoDB cluster
A simple way to shard MongoDB on the app layer.
With this approach, we have a set of replica sets. Then we can select a shard for our data based on free disk space on the DB.
For this, you need to run identical clusters (with the same size of disk space and the same storage engine)
Install it first:
npm i mongo-sharded-cluster
Using it
var MongoCluster = require('mongo-sharded-cluster');
var MongoClient = require('mongodb').MongoClient;
var async = require('async');
var myCluster = new MongoCluster();
var replSetUrls = [
{name: "one", url: "mongodb://localhost/one"},
{name: "two", url: "mongodb://localhost/two"},
];
async.each(replSetUrls, function(replSetInfo, done) {
MongoClient.connect(replSetInfo.url, function(err, db) {
if(db) {
myCluster.add(replSetInfo.name, db);
}
done(err);
});
}, function(err) {
if(err) {
throw err;
}
myCluster.startDbSizeLookup(function() {
// Pick a shard
var shardName = myCluster.pickShard();
// Then you can save this shardName in where you need.
// Get the connection for the shard
var conn = myCluster.getConnection(shardName);
});
});
You can use following helper method to initialize a cluster without hassle.
First make sure you have exports following env variables.
export MONGO_SHARD_URL_one=mongodb://localhost/one
export MONGO_SHARD_URL_two=mongodb://localhost/two
Then you can get initialize a cluster like this:
var MongoCluster = require('mongo-sharded-cluster');
MongoCluster.initFromEnv(function(err, cluster) {
if(err) {
throw err;
}
// do anything with the cluster
});
FAQs
Shard MongoDB in the app layer and build a MongoDB cluster
The npm package @monti-apm/mongo-sharded-cluster receives a total of 35 weekly downloads. As such, @monti-apm/mongo-sharded-cluster popularity was classified as not popular.
We found that @monti-apm/mongo-sharded-cluster demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.