-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Connector syncs must be triggered manually via CLI or API. There is no built-in way to schedule periodic syncs, forcing users to set up external cron jobs or scheduled tasks.
Implementation Plan
- Add schedule config to connector configuration:
{ "connectors": { "notion": { "schedule": "0 */6 * * *" } } } - Install
node-cron(or similar lightweight cron library) as a dependency - Background scheduler: Create
src/core/scheduler.ts:startScheduler(config)— reads connector configs, registers cron jobs- Each job triggers the corresponding connector sync
- Logs next-run time for each scheduled connector
- Graceful shutdown: stop all jobs on SIGTERM/SIGINT
- Integrate with
libscope serve: Start the scheduler when the API server starts - Health check enhancement: Include next-run times in
GET /api/v1/healthresponse - CLI visibility: Show schedule info in
libscope connectors status
Files to Modify
package.json— addnode-crondependencysrc/core/scheduler.ts— new file with scheduler logicsrc/api/server.ts— start scheduler on servesrc/api/routes.ts— add schedule info to health endpointsrc/config.ts— add schedule field to connector config type
Testing Strategy
- Unit test: cron expression parsing and validation
- Unit test: scheduler registers and fires jobs (mock clock)
- Unit test: graceful shutdown stops all jobs
- Integration test: configure a short interval, verify sync triggers
- Test invalid cron expressions → clear error at startup
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request