Skip to content

Commit 022cb75

Browse files
harryadelBastienRodz
authored andcommitted
Await createIndexAsync
1 parent b8fa07c commit 022cb75

File tree

5 files changed

+11
-17
lines changed

5 files changed

+11
-17
lines changed

server/imports/operator/dominator/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const dominator = {
2626

2727
let debugMode = false;
2828

29-
dominator.initialize = function () {
29+
dominator.initialize = async function () {
3030
if (debugMode) console.log("dominator.initialize", this)
3131

3232
const self = this;
@@ -43,12 +43,8 @@ dominator.initialize = function () {
4343
}
4444

4545
// Then, ensure an index is set
46-
47-
if (self.collection.createIndex) {
48-
self.collection.createIndexAsync({serverId: 1}, {unique: 1});
49-
} else {
50-
self.collection._ensureIndex({serverId: 1}, {unique: 1});
51-
}
46+
await self.collection.createIndexAsync({serverId: 1}, {unique: 1});
47+
5248

5349
// Finally, set the serverId
5450
self.serverId = Utilities.config.getServerId();

server/imports/operator/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { manager } from "./manager/"
44

55
const Operator = { dominator, queue, manager }
66

7-
Operator.start = function () {
8-
Operator.dominator.initialize();
7+
Operator.start = async function () {
8+
await Operator.dominator.initialize();
99
}
1010

1111
export { Operator }

server/imports/startup/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Operator } from "../operator/"
55
// 1. Wait 3 seconds for all the code to initialize
66
// 2. Start Jobs if autoStart is enabled
77

8-
Meteor.startup(function () {
9-
Utilities.start();
8+
Meteor.startup(async function() {
9+
await Utilities.start();
1010
Operator.start();
1111

1212
if (Utilities.config.autoStart) {

server/imports/utilities/collection/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ import { config } from "../config"
33

44
let collection;
55

6-
const initializeCollection = function () {
6+
const initializeCollection = async function () {
77
if (config.remoteCollection) {
88
const dbDriver = new MongoInternals.RemoteCollectionDriver(config.remoteCollection);
99
collection = new Mongo.Collection(config.collectionName, { _driver: dbDriver });
1010
} else {
1111
collection = new Mongo.Collection(config.collectionName);
1212
}
1313

14-
if (collection.createIndexAsync) {
15-
collection.createIndexAsync({ due: 1, state: 1 });
16-
}
14+
await collection.createIndexAsync({ due: 1, state: 1 });
1715

1816
return collection;
1917
}

server/imports/utilities/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { initializeCollection } from "./collection"
66

77
const Utilities = { config, logger, helpers, registry }
88

9-
Utilities.start = function () {
10-
Utilities.collection = initializeCollection();
9+
Utilities.start = async function () {
10+
Utilities.collection = await initializeCollection();
1111
Utilities.config.started = true;
1212
}
1313

0 commit comments

Comments
 (0)