-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc7e294
commit 8b5c2c5
Showing
8 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
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
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
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,32 @@ | ||
import { ToadScheduler } from 'toad-scheduler'; | ||
|
||
import syncDataLayer from './sync-datalayer'; | ||
import syncOrganizations from './sync-organizations'; | ||
import syncPickLists from './sync-picklists'; | ||
|
||
const scheduler = new ToadScheduler(); | ||
|
||
const jobRegistry = {}; | ||
|
||
const addJobToScheduler = (job) => { | ||
jobRegistry[job.id] = job; | ||
scheduler.addSimpleIntervalJob(job); | ||
}; | ||
|
||
const start = () => { | ||
// add default jobs | ||
const defaultJobs = [syncDataLayer, syncOrganizations, syncPickLists]; | ||
defaultJobs.forEach((defaultJob) => { | ||
jobRegistry[defaultJob.id] = defaultJob; | ||
scheduler.addSimpleIntervalJob(defaultJob); | ||
}); | ||
}; | ||
|
||
const getJobStatus = () => { | ||
return Object.keys(jobRegistry).reduce((status, key) => { | ||
status[key] = jobRegistry[key].getStatus(); | ||
return status; | ||
}, {}); | ||
}; | ||
|
||
export default { start, addJobToScheduler, jobRegistry, getJobStatus }; |
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,18 @@ | ||
import logUpdate from 'log-update'; | ||
import { SimpleIntervalJob, Task } from 'toad-scheduler'; | ||
import datalayer from '../datalayer'; | ||
const frames = ['-', '\\', '|', '/']; | ||
|
||
const task = new Task('sync-datalayer', () => { | ||
logUpdate(`Polling For Updates ${frames[Math.floor(Math.random() * 3)]}`); | ||
|
||
datalayer.startDataLayerUpdatePolling(); | ||
}); | ||
|
||
const job = new SimpleIntervalJob( | ||
{ seconds: 5, runImmediately: true }, | ||
task, | ||
'sync-datalayer', | ||
); | ||
|
||
export default job; |
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,17 @@ | ||
import { SimpleIntervalJob, Task } from 'toad-scheduler'; | ||
import { Organization } from '../models'; | ||
|
||
const task = new Task('sync-organizations', () => { | ||
console.log('Subscribing to default organizations'); | ||
if (process.env.USE_SIMULATOR === 'false') { | ||
Organization.subscribeToDefaultOrganizations(); | ||
} | ||
}); | ||
|
||
const job = new SimpleIntervalJob( | ||
{ days: 1, runImmediately: true }, | ||
task, | ||
'sync-organizations', | ||
); | ||
|
||
export default job; |
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,15 @@ | ||
import { SimpleIntervalJob, Task } from 'toad-scheduler'; | ||
import { pullPickListValues } from '../utils/data-loaders'; | ||
|
||
const task = new Task('sync-picklist', () => { | ||
console.log('Syncing Picklist Values'); | ||
pullPickListValues(); | ||
}); | ||
|
||
const job = new SimpleIntervalJob( | ||
{ days: 1, runImmediately: true }, | ||
task, | ||
'sync-picklist', | ||
); | ||
|
||
export default job; |