Skip to content

Commit

Permalink
perf: enhanced security with AI suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
oneWalker committed Nov 16, 2024
1 parent 2f46c2c commit 176ec2c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ config.schedule = {
},
},
},
//the prefix for lockedKey for redis lock
// The final Redis key pattern will be: `${prefix}-${default}-${scheduleName}`
default: 'default', // default schedule name,like project-name.
prefix: 'schedule', // default schedule prefix
};
Expand Down
3 changes: 2 additions & 1 deletion lib/strategy/all.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

const Strategy = require('./timer');
const path = require('path');

module.exports = class AllStrategy extends Strategy {
async handler() {
let canBeLocked = true;
const curConfig = this.agent?.config?.schedule;
let lockedKey = '';
if (curConfig?.cluster?.enable) {
lockedKey = this.key.replace(this.agent.baseDir, '');
lockedKey = path.relative(this.agent.baseDir, this.key);
if (!(await this.agent.lockManager.tryAcquire(lockedKey))) {
canBeLocked = false;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/strategy/worker.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
'use strict';

const Strategy = require('./timer');
const path = require('path');

module.exports = class AllStrategy extends Strategy {
async handler() {
let canBeLocked = true;
const curConfig = this.agent?.config?.schedule;
let lockedKey = '';
if (curConfig?.cluster?.enable) {
lockedKey = this.key.replace(this.agent.baseDir, '');
lockedKey = path.relative(this.agent.baseDir, this.key);
if (!(await this.agent.lockManager.tryAcquire(lockedKey))) {
canBeLocked = false;
}
Expand Down

0 comments on commit 176ec2c

Please sign in to comment.