forked from minervas/scheduled-serverless-fn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.js
20 lines (18 loc) · 871 Bytes
/
entrypoint.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// the class that contains task logic to accomplish our goals
const ScheduleWorker = require('./ScheduleWorker');
// instantiate the class
const scheduleWorker = new ScheduleWorker();
// start setting up resources that will persist between serverless invocations
const persistantResourcesReady = scheduleWorker.setupPersistentResources();
module.exports.scheduleFunction = async () => {
// wait for persist
await persistantResourcesReady;
// check if any persistent resources expired between invocations
await scheduleWorker.refreshResources();
// set up resources that should only exist during the function invocation
await scheduleWorker.setupEphemeralResources();
// complete the scheduled task
await scheduleWorker.doWork();
// clean up resources that should only exist during the function invocation
await scheduleWorker.cleanUpResources();
};