zen-fs-config 0.3.4 → 0.3.6
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/dist/index.js +50 -41
- package/dist/index.mjs +50 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1311,23 +1311,27 @@ async function createConfigRepo(appId, options) {
|
|
|
1311
1311
|
void 0
|
|
1312
1312
|
);
|
|
1313
1313
|
let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
|
|
1314
|
-
if (!backendsMeta && options.bootstrap) {
|
|
1315
|
-
backendsMeta = {
|
|
1316
|
-
version: 1,
|
|
1317
|
-
backends: options.bootstrap.backends
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
1314
|
if (!backendsMeta) {
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1315
|
+
if (options.bootstrap) {
|
|
1316
|
+
backendsMeta = {
|
|
1317
|
+
version: 1,
|
|
1318
|
+
backends: options.bootstrap.backends
|
|
1319
|
+
};
|
|
1320
|
+
console.log(`[createConfigRepo] First init: using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
|
|
1321
|
+
} else {
|
|
1322
|
+
backendsMeta = {
|
|
1323
|
+
version: 1,
|
|
1324
|
+
backends: [
|
|
1325
|
+
{
|
|
1326
|
+
id: options.primaryBackendId,
|
|
1327
|
+
type: options.backendInfo.type,
|
|
1328
|
+
options: options.backendInfo.options
|
|
1329
|
+
}
|
|
1330
|
+
]
|
|
1331
|
+
};
|
|
1332
|
+
}
|
|
1333
|
+
} else {
|
|
1334
|
+
console.log(`[createConfigRepo] Reconnect: using stored backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
|
|
1331
1335
|
}
|
|
1332
1336
|
const hasPrimary = backendsMeta.backends.some(
|
|
1333
1337
|
(b) => b.id === options.primaryBackendId
|
|
@@ -1341,32 +1345,37 @@ async function createConfigRepo(appId, options) {
|
|
|
1341
1345
|
}
|
|
1342
1346
|
await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
|
|
1343
1347
|
let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
|
|
1344
|
-
if (!syncRulesMeta && options.bootstrap) {
|
|
1345
|
-
syncRulesMeta = {
|
|
1346
|
-
version: 1,
|
|
1347
|
-
rules: options.bootstrap.syncRules
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
1348
|
if (!syncRulesMeta) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1349
|
+
if (options.bootstrap) {
|
|
1350
|
+
syncRulesMeta = {
|
|
1351
|
+
version: 1,
|
|
1352
|
+
rules: options.bootstrap.syncRules
|
|
1353
|
+
};
|
|
1354
|
+
console.log(`[createConfigRepo] First init: using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
|
|
1355
|
+
} else {
|
|
1356
|
+
syncRulesMeta = {
|
|
1357
|
+
version: 1,
|
|
1358
|
+
rules: [
|
|
1359
|
+
{
|
|
1360
|
+
prefix: `/${appId}/`,
|
|
1361
|
+
direction: "one-way",
|
|
1362
|
+
conflictStrategy: "source-wins",
|
|
1363
|
+
replicas: backendsMeta.backends.map((b) => b.id)
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
prefix: `${SHARED_DIR}/`,
|
|
1367
|
+
direction: "bi-directional",
|
|
1368
|
+
conflictStrategy: "merge",
|
|
1369
|
+
replicas: backendsMeta.backends.map((b) => b.id)
|
|
1370
|
+
},
|
|
1371
|
+
{ prefix: `${NODES_DIR}/`, direction: "none" },
|
|
1372
|
+
{ prefix: `${META_DIR}/`, direction: "none" }
|
|
1373
|
+
]
|
|
1374
|
+
};
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
if (syncRulesMeta) {
|
|
1378
|
+
console.log(`[createConfigRepo] Reconnect: using stored syncRules: ${syncRulesMeta.rules.length} rules`);
|
|
1370
1379
|
}
|
|
1371
1380
|
await tempRepo.writeMetaFile(SYNC_RULES_FILE, syncRulesMeta);
|
|
1372
1381
|
let nodeId = options.nodeId;
|
package/dist/index.mjs
CHANGED
|
@@ -1264,23 +1264,27 @@ async function createConfigRepo(appId, options) {
|
|
|
1264
1264
|
void 0
|
|
1265
1265
|
);
|
|
1266
1266
|
let backendsMeta = await tempRepo.readMetaFile(BACKENDS_FILE);
|
|
1267
|
-
if (!backendsMeta && options.bootstrap) {
|
|
1268
|
-
backendsMeta = {
|
|
1269
|
-
version: 1,
|
|
1270
|
-
backends: options.bootstrap.backends
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
1267
|
if (!backendsMeta) {
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1268
|
+
if (options.bootstrap) {
|
|
1269
|
+
backendsMeta = {
|
|
1270
|
+
version: 1,
|
|
1271
|
+
backends: options.bootstrap.backends
|
|
1272
|
+
};
|
|
1273
|
+
console.log(`[createConfigRepo] First init: using bootstrap backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
|
|
1274
|
+
} else {
|
|
1275
|
+
backendsMeta = {
|
|
1276
|
+
version: 1,
|
|
1277
|
+
backends: [
|
|
1278
|
+
{
|
|
1279
|
+
id: options.primaryBackendId,
|
|
1280
|
+
type: options.backendInfo.type,
|
|
1281
|
+
options: options.backendInfo.options
|
|
1282
|
+
}
|
|
1283
|
+
]
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
} else {
|
|
1287
|
+
console.log(`[createConfigRepo] Reconnect: using stored backends: ${backendsMeta.backends.map((b) => b.id).join(", ")}`);
|
|
1284
1288
|
}
|
|
1285
1289
|
const hasPrimary = backendsMeta.backends.some(
|
|
1286
1290
|
(b) => b.id === options.primaryBackendId
|
|
@@ -1294,32 +1298,37 @@ async function createConfigRepo(appId, options) {
|
|
|
1294
1298
|
}
|
|
1295
1299
|
await tempRepo.writeMetaFile(BACKENDS_FILE, backendsMeta);
|
|
1296
1300
|
let syncRulesMeta = await tempRepo.readMetaFile(SYNC_RULES_FILE);
|
|
1297
|
-
if (!syncRulesMeta && options.bootstrap) {
|
|
1298
|
-
syncRulesMeta = {
|
|
1299
|
-
version: 1,
|
|
1300
|
-
rules: options.bootstrap.syncRules
|
|
1301
|
-
};
|
|
1302
|
-
}
|
|
1303
1301
|
if (!syncRulesMeta) {
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1302
|
+
if (options.bootstrap) {
|
|
1303
|
+
syncRulesMeta = {
|
|
1304
|
+
version: 1,
|
|
1305
|
+
rules: options.bootstrap.syncRules
|
|
1306
|
+
};
|
|
1307
|
+
console.log(`[createConfigRepo] First init: using bootstrap syncRules: ${syncRulesMeta.rules.length} rules`);
|
|
1308
|
+
} else {
|
|
1309
|
+
syncRulesMeta = {
|
|
1310
|
+
version: 1,
|
|
1311
|
+
rules: [
|
|
1312
|
+
{
|
|
1313
|
+
prefix: `/${appId}/`,
|
|
1314
|
+
direction: "one-way",
|
|
1315
|
+
conflictStrategy: "source-wins",
|
|
1316
|
+
replicas: backendsMeta.backends.map((b) => b.id)
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
prefix: `${SHARED_DIR}/`,
|
|
1320
|
+
direction: "bi-directional",
|
|
1321
|
+
conflictStrategy: "merge",
|
|
1322
|
+
replicas: backendsMeta.backends.map((b) => b.id)
|
|
1323
|
+
},
|
|
1324
|
+
{ prefix: `${NODES_DIR}/`, direction: "none" },
|
|
1325
|
+
{ prefix: `${META_DIR}/`, direction: "none" }
|
|
1326
|
+
]
|
|
1327
|
+
};
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
if (syncRulesMeta) {
|
|
1331
|
+
console.log(`[createConfigRepo] Reconnect: using stored syncRules: ${syncRulesMeta.rules.length} rules`);
|
|
1323
1332
|
}
|
|
1324
1333
|
await tempRepo.writeMetaFile(SYNC_RULES_FILE, syncRulesMeta);
|
|
1325
1334
|
let nodeId = options.nodeId;
|