-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement ObjectID to replace mongodb
We need to remove code related to mongodb as we are using postgrace. This is to be done in steps and first step is to implement ObjectId class and replace mongodb.ObjectId calls with that class. Signed-off-by: Ashish Pandey <[email protected]>
- Loading branch information
Showing
27 changed files
with
320 additions
and
129 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,14 @@ | |
// const _ = require('lodash'); | ||
const argv = require('minimist')(process.argv); | ||
const cluster = require('cluster'); | ||
const mongodb = require('mongodb'); | ||
|
||
const api = require('../api'); | ||
const config = require('../../config'); | ||
const dotenv = require('../util/dotenv'); | ||
const Speedometer = require('../util/speedometer'); | ||
const { RPC_BUFFERS } = require('../rpc'); | ||
|
||
const ObjectID = require('../util/objectid'); | ||
dotenv.load(); | ||
|
||
argv.email = argv.email || '[email protected]'; | ||
|
@@ -60,7 +60,7 @@ async function worker(client) { | |
} | ||
|
||
async function write_block(client) { | ||
const block_id = new mongodb.ObjectId(); | ||
const block_id = new ObjectID(null); | ||
return client.block_store.write_block({ | ||
[RPC_BUFFERS]: { data: Buffer.allocUnsafe(argv.size) }, | ||
block_md: { | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* Copyright (C) 2016 NooBaa */ | ||
|
||
/** | ||
* Represents a BSON ObjectID type. | ||
*/ | ||
declare interface ObjectID { | ||
readonly id: string | Buffer; | ||
readonly str: string; | ||
|
||
toHexString(): string; | ||
equals(other: ObjectID | string): boolean; | ||
getTimestamp(): Date; | ||
generate(time?: number): string; | ||
toJSON(): string; | ||
toString(): string; | ||
} | ||
|
||
/** | ||
* Constructor and utility functions for the ObjectID type. | ||
*/ | ||
declare interface ObjectIDConstructor { | ||
new(id?: string | number | Buffer): ObjectID; | ||
isValid(id: string | Buffer | ObjectID): boolean; | ||
(id?: string | number | Buffer): ObjectID; | ||
} | ||
|
||
/** | ||
* The ObjectID constructor and utilities. | ||
*/ | ||
declare const ObjectID: ObjectIDConstructor; | ||
|
||
export = ObjectID; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.