-
$ mkdir -p /data/configdb -
$ mongod --configsvr --port 27010starta mongod -
$ mongos --configdb localhost:27010 --port 27011cria router -
$ mkdir /data/shard1 && mkdir /data/shard2 && mkdir /data/shard3cria pasta pros shards -
Start shards
$ mongod --port 27012 --dbpath /data/shard1 # shard1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Option, none, some } from 'fp-ts/lib/Option' | |
| import { TaskEither, fromLeft, taskEither } from 'fp-ts/lib/TaskEither' | |
| const a = (): Option<number> => { | |
| if (Math.random() > 0.5) { | |
| return none | |
| } | |
| return some(1) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface ILocation { | |
| cc: string | |
| admin1: string | |
| admin2: string | |
| } | |
| const location: Option<Partial<ILocation>> = some({cc: 'BR', admin1: 'SC'}) | |
| const first = 100 | |
| const offset = 10 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const compose = (...fn) => x => | |
| fn.reduceRight((prevResult, func) => func(prevResult), x) | |
| /* | |
| const randomFloat = n => Math.random() * n | |
| const nToStr = n => String(n) | |
| const pad4 = str => str.padStart(4, '0') | |
| const randomInt = compose(pad4, nToStr, Math.floor, randomFloat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -='cd -' | |
| ...=../.. | |
| ....=../../.. | |
| .....=../../../.. | |
| ......=../../../../.. | |
| 1='cd -' | |
| 2='cd -2' | |
| 3='cd -3' | |
| 4='cd -4' | |
| 5='cd -5' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| var readline = require('readline'), | |
| unflatten = require('flat').unflatten, | |
| logfmt = require('logfmt'); | |
| var rl = readline.createInterface({ | |
| input: process.stdin, | |
| output: process.stdout | |
| }); |