Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
1235ae2eb3 | |||
8166d2f7c2 | |||
7c9f27e02f | |||
842e4b280b |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@push.rocks/smartdata",
|
"name": "@push.rocks/smartdata",
|
||||||
"version": "5.0.27",
|
"version": "5.0.29",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "do more with data",
|
"description": "do more with data",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -30,8 +30,8 @@
|
|||||||
"@push.rocks/smartrx": "^3.0.6",
|
"@push.rocks/smartrx": "^3.0.6",
|
||||||
"@push.rocks/smartstring": "^4.0.7",
|
"@push.rocks/smartstring": "^4.0.7",
|
||||||
"@push.rocks/smarttime": "^4.0.5",
|
"@push.rocks/smarttime": "^4.0.5",
|
||||||
"@push.rocks/smartunique": "^3.0.3",
|
"@push.rocks/smartunique": "^3.0.6",
|
||||||
"@push.rocks/taskbuffer": "^3.1.3",
|
"@push.rocks/taskbuffer": "^3.1.5",
|
||||||
"@tsclass/tsclass": "^4.0.42",
|
"@tsclass/tsclass": "^4.0.42",
|
||||||
"mongodb": "^5.7.0"
|
"mongodb": "^5.7.0"
|
||||||
},
|
},
|
||||||
|
703
pnpm-lock.yaml
generated
703
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,7 @@ tap.test('SmartdataDistributedCoordinator should update distributed task request
|
|||||||
|
|
||||||
const mockTaskRequest: taskbuffer.distributedCoordination.IDistributedTaskRequest = {
|
const mockTaskRequest: taskbuffer.distributedCoordination.IDistributedTaskRequest = {
|
||||||
submitterId: "mockSubmitter12345", // Some unique mock submitter ID
|
submitterId: "mockSubmitter12345", // Some unique mock submitter ID
|
||||||
|
requestResponseId: 'uni879873462hjhfkjhsdf', // Some unique ID for the request-response
|
||||||
taskName: "SampleTask",
|
taskName: "SampleTask",
|
||||||
taskVersion: "1.0.0", // Assuming it's a version string
|
taskVersion: "1.0.0", // Assuming it's a version string
|
||||||
taskExecutionTime: Date.now(),
|
taskExecutionTime: Date.now(),
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@push.rocks/smartdata',
|
name: '@push.rocks/smartdata',
|
||||||
version: '5.0.27',
|
version: '5.0.29',
|
||||||
description: 'do more with data'
|
description: 'do more with data'
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ export class SmartdataCollection<T> {
|
|||||||
* if this.objectValidation is not set it passes.
|
* if this.objectValidation is not set it passes.
|
||||||
*/
|
*/
|
||||||
private checkDoc(docArg: T): Promise<void> {
|
private checkDoc(docArg: T): Promise<void> {
|
||||||
const done = plugins.smartq.defer<void>();
|
const done = plugins.smartpromise.defer<void>();
|
||||||
let validationResult = true;
|
let validationResult = true;
|
||||||
if (this.objectValidation) {
|
if (this.objectValidation) {
|
||||||
validationResult = this.objectValidation(docArg);
|
validationResult = this.objectValidation(docArg);
|
||||||
|
@ -11,7 +11,7 @@ export class DistributedClass extends SmartDataDbDoc<DistributedClass, Distribut
|
|||||||
|
|
||||||
@svDb()
|
@svDb()
|
||||||
public data: {
|
public data: {
|
||||||
status: 'bidding' | 'settled' | 'initializing' | 'stopped';
|
status: 'initializing' | 'bidding' | 'settled' | 'stopped';
|
||||||
biddingShortcode?: string;
|
biddingShortcode?: string;
|
||||||
biddingStartTime?: number;
|
biddingStartTime?: number;
|
||||||
lastUpdated: number;
|
lastUpdated: number;
|
||||||
@ -174,7 +174,7 @@ export class SmartdataDistributedCoordinator extends plugins.taskbuffer.distribu
|
|||||||
});
|
});
|
||||||
console.log(`bidding for leadership...`);
|
console.log(`bidding for leadership...`);
|
||||||
await plugins.smartdelay.delayFor(
|
await plugins.smartdelay.delayFor(
|
||||||
plugins.smarttime.getMilliSecondsFromUnits({ seconds: 20 })
|
plugins.smarttime.getMilliSecondsFromUnits({ seconds: 5 })
|
||||||
);
|
);
|
||||||
await this.asyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
await this.asyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||||
let biddingInstances = await DistributedClass.getInstances({});
|
let biddingInstances = await DistributedClass.getInstances({});
|
||||||
@ -182,7 +182,7 @@ export class SmartdataDistributedCoordinator extends plugins.taskbuffer.distribu
|
|||||||
(instanceArg) =>
|
(instanceArg) =>
|
||||||
instanceArg.data.status === 'bidding' &&
|
instanceArg.data.status === 'bidding' &&
|
||||||
instanceArg.data.lastUpdated >=
|
instanceArg.data.lastUpdated >=
|
||||||
Date.now() - plugins.smarttime.getMilliSecondsFromUnits({ seconds: 25 })
|
Date.now() - plugins.smarttime.getMilliSecondsFromUnits({ seconds: 6 })
|
||||||
);
|
);
|
||||||
console.log(`found ${biddingInstances.length} bidding instances...`);
|
console.log(`found ${biddingInstances.length} bidding instances...`);
|
||||||
this.ownInstance.data.elected = true;
|
this.ownInstance.data.elected = true;
|
||||||
@ -234,9 +234,12 @@ export class SmartdataDistributedCoordinator extends plugins.taskbuffer.distribu
|
|||||||
console.error('instance need to be started first...');
|
console.error('instance need to be started first...');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await this.ownInstance.updateFromDb();
|
||||||
this.ownInstance.data.taskRequests.push(taskRequestArg);
|
this.ownInstance.data.taskRequests.push(taskRequestArg);
|
||||||
await this.ownInstance.save();
|
await this.ownInstance.save();
|
||||||
});
|
});
|
||||||
|
await plugins.smartdelay.delayFor(10000);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import * as lik from '@push.rocks/lik';
|
|||||||
import * as smartdelay from '@push.rocks/smartdelay';
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
import * as smartlog from '@push.rocks/smartlog';
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
import * as smartpromise from '@push.rocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartq from '@push.rocks/smartpromise';
|
|
||||||
import * as smartrx from '@push.rocks/smartrx';
|
import * as smartrx from '@push.rocks/smartrx';
|
||||||
import * as smartstring from '@push.rocks/smartstring';
|
import * as smartstring from '@push.rocks/smartstring';
|
||||||
import * as smarttime from '@push.rocks/smarttime';
|
import * as smarttime from '@push.rocks/smarttime';
|
||||||
@ -21,7 +20,6 @@ export {
|
|||||||
smartdelay,
|
smartdelay,
|
||||||
smartpromise,
|
smartpromise,
|
||||||
smartlog,
|
smartlog,
|
||||||
smartq,
|
|
||||||
smartrx,
|
smartrx,
|
||||||
mongodb,
|
mongodb,
|
||||||
smartstring,
|
smartstring,
|
||||||
|
Reference in New Issue
Block a user