@autofleet/node-common 1.1.62 → 1.1.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/queue/index.js +6 -8
- package/settings/index.js +5 -0
- package/settings/map.js +265 -0
package/package.json
CHANGED
package/queue/index.js
CHANGED
|
@@ -28,6 +28,11 @@ class AfQueue {
|
|
|
28
28
|
|
|
29
29
|
this.existing = true;
|
|
30
30
|
logger.info('Will remove AfQueue');
|
|
31
|
+
|
|
32
|
+
if (this.worker) {
|
|
33
|
+
await this.worker.end();
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
if (this.queue) {
|
|
32
37
|
await this.queue.end();
|
|
33
38
|
}
|
|
@@ -36,13 +41,7 @@ class AfQueue {
|
|
|
36
41
|
await this.scheduler.end();
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
if (this.worker) {
|
|
41
|
-
this.worker.on('end', process.exit);
|
|
42
|
-
await this.worker.end();
|
|
43
|
-
} else {
|
|
44
|
-
process.exit();
|
|
45
|
-
}
|
|
44
|
+
process.exit();
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
async init(connectionDetails, workerSettings, shouldCreateQueue = true) {
|
|
@@ -62,7 +61,6 @@ class AfQueue {
|
|
|
62
61
|
promiseArr.push(this.startWorker(redisConf, workerSettings));
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
process.on('SIGINT', this.exitHandler.bind(this));
|
|
66
64
|
process.on('SIGINT', this.exitHandler.bind(this));
|
|
67
65
|
process.on('SIGTERM', this.exitHandler.bind(this));
|
|
68
66
|
|
package/settings/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const EventEmitter = require('events');
|
|
|
2
2
|
const NodeCache = require('node-cache');
|
|
3
3
|
const Network = require('../network');
|
|
4
4
|
const Logger = require('../logger');
|
|
5
|
+
const keysMap = require('./map');
|
|
5
6
|
|
|
6
7
|
const logger = Logger();
|
|
7
8
|
require('dotenv').config();
|
|
@@ -32,6 +33,10 @@ module.exports = class SettingsManager {
|
|
|
32
33
|
if (typeof defaultValue === 'undefined') {
|
|
33
34
|
throw new Error('Can\'t get a key without defaultValue');
|
|
34
35
|
}
|
|
36
|
+
if (!keysMap[key]) {
|
|
37
|
+
// TODO: Throw error here after done with mapping all keys
|
|
38
|
+
logger.error(`Try to get settings for unknown key: ${key}`);
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
const cacheKey = `${key}_${JSON.stringify(labels)}`;
|
|
37
42
|
const cacheValue = this.settingsCache.get(cacheKey);
|
package/settings/map.js
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
MAP_PROVIDER: {
|
|
3
|
+
name: 'Map provider',
|
|
4
|
+
description: 'The map provider',
|
|
5
|
+
type: 'string',
|
|
6
|
+
defaultValue: 'osrm',
|
|
7
|
+
context: 'maps',
|
|
8
|
+
},
|
|
9
|
+
H3_LEVEL: {
|
|
10
|
+
name: 'H3 level',
|
|
11
|
+
description: '',
|
|
12
|
+
type: 'number',
|
|
13
|
+
defaultValue: 8,
|
|
14
|
+
context: 'maps',
|
|
15
|
+
},
|
|
16
|
+
DEMAND_PREDICTION_MODEL: {
|
|
17
|
+
name: 'Demand prediction model',
|
|
18
|
+
description: 'Some des',
|
|
19
|
+
type: 'string',
|
|
20
|
+
defaultValue: '@london',
|
|
21
|
+
context: 'demand prediction',
|
|
22
|
+
},
|
|
23
|
+
MIN_SHIFT_TIME_FOR_INFLEET_HOURS: {
|
|
24
|
+
name: 'Minimum shift time for infleet',
|
|
25
|
+
description: 'Minimum left time on shift in hours for infleet',
|
|
26
|
+
type: 'number',
|
|
27
|
+
defaultValue: 0,
|
|
28
|
+
context: 'indefleet',
|
|
29
|
+
},
|
|
30
|
+
FLEETING_INFLEET_THRESHOLD: {
|
|
31
|
+
name: 'Infleet threshold',
|
|
32
|
+
description: 'Minimum vehicles for start infleet',
|
|
33
|
+
type: 'number',
|
|
34
|
+
defaultValue: 0,
|
|
35
|
+
context: 'indefleet',
|
|
36
|
+
},
|
|
37
|
+
FLEETING_DEFLEET_THRESHOLD: {
|
|
38
|
+
name: 'Defleet threshold',
|
|
39
|
+
description: 'Minimum vehicles for start defleet',
|
|
40
|
+
type: 'number',
|
|
41
|
+
defaultValue: 0,
|
|
42
|
+
context: 'indefleet',
|
|
43
|
+
},
|
|
44
|
+
FLEET_WEIGHTS: { // ?
|
|
45
|
+
name: 'FLEET_WEIGHTS',
|
|
46
|
+
description: '',
|
|
47
|
+
type: 'json',
|
|
48
|
+
defaultValue: [4],
|
|
49
|
+
context: 'indefleet',
|
|
50
|
+
},
|
|
51
|
+
FLEETING_CORRELATION_COEFFICIENT: { // ?
|
|
52
|
+
name: 'Indefleet HRPV',
|
|
53
|
+
description: '',
|
|
54
|
+
type: 'number',
|
|
55
|
+
defaultValue: 4,
|
|
56
|
+
context: 'indefleet',
|
|
57
|
+
},
|
|
58
|
+
// FLEETING_DEMAND_CALCULATION_TIME_MARGIN_MINUTES ??
|
|
59
|
+
// FLEETING_DEMAND_CALCULATION_INTERVAL, FLEETING_DEMAND_CALCULATION_INTERVALS ??
|
|
60
|
+
ALLOW_STOP_POINT_OUTSIDE_TERRITORY: {
|
|
61
|
+
name: 'Allow stop points outside territory',
|
|
62
|
+
description: '',
|
|
63
|
+
type: 'string',
|
|
64
|
+
defaultValue: 'all',
|
|
65
|
+
enum: ['all', 'none', 'first', 'last'],
|
|
66
|
+
context: 'matching',
|
|
67
|
+
},
|
|
68
|
+
VEHICLE_SEARCH_RADIUS: {
|
|
69
|
+
name: 'Matching search radius',
|
|
70
|
+
description: 'The meters for searching vehicles on matching',
|
|
71
|
+
type: 'number',
|
|
72
|
+
defaultValue: 15000,
|
|
73
|
+
context: 'matching',
|
|
74
|
+
},
|
|
75
|
+
ETA_MAX: {
|
|
76
|
+
name: 'Maximum time to pickup',
|
|
77
|
+
description: 'The maximum allowed time to pickup in matching',
|
|
78
|
+
type: 'number',
|
|
79
|
+
defaultValue: 15,
|
|
80
|
+
context: 'matching',
|
|
81
|
+
},
|
|
82
|
+
MIN_RANGE_FOR_MATCHING: {
|
|
83
|
+
name: 'Minimum fuel range for matching',
|
|
84
|
+
description: 'The minimum im meters fuel range for vehicle to taking part in matching',
|
|
85
|
+
type: 'number',
|
|
86
|
+
defaultValue: 10000,
|
|
87
|
+
context: 'matching',
|
|
88
|
+
},
|
|
89
|
+
FLEET_SCORE_WEIGHT: {
|
|
90
|
+
name: 'Fleet score weight',
|
|
91
|
+
description: 'The fleet score weight 0-1',
|
|
92
|
+
type: 'number',
|
|
93
|
+
defaultValue: 0.5,
|
|
94
|
+
context: 'matching',
|
|
95
|
+
},
|
|
96
|
+
UNPAID_MAX: { // ?
|
|
97
|
+
name: 'unpaid max',
|
|
98
|
+
description: '',
|
|
99
|
+
type: 'number',
|
|
100
|
+
defaultValue: 20,
|
|
101
|
+
context: 'matching',
|
|
102
|
+
},
|
|
103
|
+
ETA_MIN: { // ?
|
|
104
|
+
name: 'ETA min',
|
|
105
|
+
description: '',
|
|
106
|
+
type: 'number',
|
|
107
|
+
defaultValue: 5,
|
|
108
|
+
context: 'matching',
|
|
109
|
+
},
|
|
110
|
+
VEHICLE_REROUTE_INTERVAL_SECONDS: {
|
|
111
|
+
name: 'Reroute interval',
|
|
112
|
+
description: 'Vehicles reroute interval in seconds',
|
|
113
|
+
type: 'number',
|
|
114
|
+
defaultValue: 300,
|
|
115
|
+
context: 'route',
|
|
116
|
+
},
|
|
117
|
+
METERS_FOR_CALC_NEW_ROUTE: {
|
|
118
|
+
name: 'Meters for re-calculation route',
|
|
119
|
+
description: 'The distance im meters to recalc the route',
|
|
120
|
+
type: 'number',
|
|
121
|
+
defaultValue: 20,
|
|
122
|
+
context: 'route',
|
|
123
|
+
},
|
|
124
|
+
MIN_RANGE_TO_FUEL_METERS: {
|
|
125
|
+
name: 'Fuel threshold',
|
|
126
|
+
description: 'The vehicle range in meters to get fuel',
|
|
127
|
+
type: 'number',
|
|
128
|
+
defaultValue: 50000,
|
|
129
|
+
context: 'fuel',
|
|
130
|
+
},
|
|
131
|
+
DRIVER_MAX_MIN_TO_FUEL: {
|
|
132
|
+
name: 'Maximum time for fuel',
|
|
133
|
+
description: 'The maximum time in minutes for driver done with fuel',
|
|
134
|
+
type: 'number',
|
|
135
|
+
defaultValue: 15,
|
|
136
|
+
context: 'fuel',
|
|
137
|
+
},
|
|
138
|
+
// TODO: MAPPING_S2_LEVEL?
|
|
139
|
+
PLACEMENT_INTERVAL: { // TODO: per fleet + there is also PLACEMENT_INTERVAL_MIN WTF?!
|
|
140
|
+
name: 'Placement interval',
|
|
141
|
+
description: '',
|
|
142
|
+
type: 'number',
|
|
143
|
+
defaultValue: 30,
|
|
144
|
+
context: 'placement',
|
|
145
|
+
},
|
|
146
|
+
PLACEMENT_CORRELATION_COEFFICIENT: { // TODO: per fleet
|
|
147
|
+
name: 'HRPV',
|
|
148
|
+
description: 'PLACEMENT_CORRELATION_COEFFICIENT',
|
|
149
|
+
type: 'number',
|
|
150
|
+
defaultValue: 1,
|
|
151
|
+
context: 'placement',
|
|
152
|
+
},
|
|
153
|
+
PLACEMENT_POSITIVE_THRESHOLD: { // TODO: per fleet
|
|
154
|
+
name: 'Placement positive threshold',
|
|
155
|
+
description: 'PLACEMENT_POSITIVE_THRESHOLD',
|
|
156
|
+
type: 'number',
|
|
157
|
+
defaultValue: 1.1,
|
|
158
|
+
context: 'placement',
|
|
159
|
+
},
|
|
160
|
+
PLACEMENT_NEGATIVE_THRESHOLD: { // TODO: per fleet
|
|
161
|
+
name: 'Placement negative threshold',
|
|
162
|
+
description: 'PLACEMENT_NEGATIVE_THRESHOLD',
|
|
163
|
+
type: 'number',
|
|
164
|
+
defaultValue: 0.9,
|
|
165
|
+
context: 'placement',
|
|
166
|
+
},
|
|
167
|
+
DRIVER_MAX_MINUTES_TO_COME_BACK: {
|
|
168
|
+
name: 'Parking threshold',
|
|
169
|
+
description: 'Minuets before the end of the shift for vehicles to get parking',
|
|
170
|
+
type: 'number',
|
|
171
|
+
defaultValue: 40,
|
|
172
|
+
context: 'shifts',
|
|
173
|
+
},
|
|
174
|
+
EMERGENCY_NUMBER: {
|
|
175
|
+
name: 'Minimum shift time for infleet',
|
|
176
|
+
description: 'Minimum left time on shift in hours for infleet',
|
|
177
|
+
type: 'string',
|
|
178
|
+
defaultValue: '972525893052',
|
|
179
|
+
context: 'operation',
|
|
180
|
+
},
|
|
181
|
+
REFRESH_TOKEN_DRIVER_EXPIRES_IN_ZEITMS_FORMAT: {
|
|
182
|
+
name: 'Driver refresh token expires',
|
|
183
|
+
description: 'The driver token expires in Zeitms format',
|
|
184
|
+
type: 'string',
|
|
185
|
+
defaultValue: '1y',
|
|
186
|
+
context: 'security',
|
|
187
|
+
},
|
|
188
|
+
CANCEL_BREAK_MILLI: {
|
|
189
|
+
name: 'Cancel break mili', // TODO: grave time
|
|
190
|
+
description: '',
|
|
191
|
+
type: 'number',
|
|
192
|
+
defaultValue: 30 * 1000,
|
|
193
|
+
context: 'operation',
|
|
194
|
+
},
|
|
195
|
+
MAX_BREAK_TIME_MILLI: {
|
|
196
|
+
name: 'Max break time',
|
|
197
|
+
description: 'The duration of break in miliseconds',
|
|
198
|
+
type: 'number',
|
|
199
|
+
defaultValue: 10 * 60 * 1000,
|
|
200
|
+
context: 'operation',
|
|
201
|
+
},
|
|
202
|
+
MAX_BREAKS_PER_SHIFT: {
|
|
203
|
+
name: 'Maximum breaks per shift',
|
|
204
|
+
description: 'The number of breaks that driver can take during shift',
|
|
205
|
+
type: 'number',
|
|
206
|
+
defaultValue: 5,
|
|
207
|
+
context: 'operation',
|
|
208
|
+
},
|
|
209
|
+
MIN_TIME_BETWEEN_BREAKS_MILLI: {
|
|
210
|
+
name: 'Minimum time between breaks',
|
|
211
|
+
description: 'The minimum time in miliseconds for taking another break',
|
|
212
|
+
type: 'number',
|
|
213
|
+
defaultValue: 60 * 60 * 1000,
|
|
214
|
+
context: 'operation',
|
|
215
|
+
},
|
|
216
|
+
MAXIMUN_RIDES_PER_TILE_ON_MAP: {
|
|
217
|
+
name: 'Maximum rides per tile on CC map',
|
|
218
|
+
description: '',
|
|
219
|
+
type: 'number',
|
|
220
|
+
defaultValue: 15,
|
|
221
|
+
context: 'operation',
|
|
222
|
+
},
|
|
223
|
+
DRIVER_APP_SP_VALIDATION_POPUP_DISTANCE: {
|
|
224
|
+
name: 'Distance for pop done in stop point validation',
|
|
225
|
+
description: 'Driver app - distance (km) from stop point for pop validation',
|
|
226
|
+
type: 'number',
|
|
227
|
+
defaultValue: 0.7,
|
|
228
|
+
context: 'operation',
|
|
229
|
+
},
|
|
230
|
+
FLEETING_ACTIVATION_EXPIERY_HOURS: { // TODO: there is also ACTIVATION_EXPIERY WTF?!
|
|
231
|
+
name: 'Activation expiery hours',
|
|
232
|
+
description: 'Hours from start to activate until the activation will cancel',
|
|
233
|
+
type: 'number',
|
|
234
|
+
defaultValue: 2,
|
|
235
|
+
context: 'operation',
|
|
236
|
+
},
|
|
237
|
+
DEMAND_GATEWAY_SECRET: {
|
|
238
|
+
name: 'Demand gateway secret',
|
|
239
|
+
description: '',
|
|
240
|
+
type: 'string',
|
|
241
|
+
defaultValue: 1234,
|
|
242
|
+
context: 'security',
|
|
243
|
+
},
|
|
244
|
+
REFRESH_TOKEN_EXPIRES_IN_ZEITMS_FORMAT: { // TODO: per fleet
|
|
245
|
+
name: 'Fleet user token expires in zeitms foramt',
|
|
246
|
+
description: '',
|
|
247
|
+
type: 'string',
|
|
248
|
+
defaultValue: '90d',
|
|
249
|
+
context: 'security',
|
|
250
|
+
},
|
|
251
|
+
CC_MIN_TO_RESET_WRONG_PASSWORD_COUNTER: { // TODO: per fleet
|
|
252
|
+
name: 'Minutes to reset wrong password in CC',
|
|
253
|
+
description: '',
|
|
254
|
+
type: 'number',
|
|
255
|
+
defaultValue: 30,
|
|
256
|
+
context: 'security',
|
|
257
|
+
},
|
|
258
|
+
CC_WRONG_PASSWORD_ATTEMPTS: { // TODO: per fleet
|
|
259
|
+
name: 'Wrong password attempts in CC',
|
|
260
|
+
description: '',
|
|
261
|
+
type: 'number',
|
|
262
|
+
defaultValue: 5,
|
|
263
|
+
context: 'security',
|
|
264
|
+
},
|
|
265
|
+
};
|