-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: run cron job to start signature request processing
Without this patch we rely on users making a POST request to /v1/signature-requests/process to kick off signature request processing. Since it's not going to be high load, we want to have a regular cron job that relieves users of that duty and will run signature request validations on autopilot. This way users just have to wait a bit to find their signature requests validated once the Safe message has reached the required threshold. Also made a small change to the log statement in the processor to make it more clear that it's running signature requests, now that a console log will show up every 30 seconds.
- Loading branch information
1 parent
126e4eb
commit 4baee53
Showing
5 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import cron from "node-cron"; | ||
|
||
import SignatureRequestProcessor from "../services/SignatureRequestProcessor.js"; | ||
|
||
export default class SignatureRequestProcessorCron { | ||
private static instance: SignatureRequestProcessorCron; | ||
private processor: SignatureRequestProcessor; | ||
|
||
private constructor() { | ||
this.processor = SignatureRequestProcessor.getInstance(); | ||
this.setupCronJob(); | ||
} | ||
|
||
private setupCronJob() { | ||
// Run every 30 seconds | ||
cron.schedule("*/30 * * * * *", async () => { | ||
try { | ||
await this.processor.processPendingRequests(); | ||
} catch (error) { | ||
console.error("Error in signature request processor cron job:", error); | ||
} | ||
}); | ||
} | ||
|
||
public static start(): void { | ||
if (!SignatureRequestProcessorCron.instance) { | ||
SignatureRequestProcessorCron.instance = | ||
new SignatureRequestProcessorCron(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters