Skip to content

Latest commit

 

History

History
45 lines (28 loc) · 1.83 KB

index.rst

File metadata and controls

45 lines (28 loc) · 1.83 KB

Runnable Components

Jivago provides a mechanism for running background tasks and exposes application initialization hooks. For both of those purposes, the Runnable interface is used.

runnable.py

Background Workers

For running continuous tasks on a background thread, use the @BackgroundWorker annotation. These components will be started on separate threads when the app has started successfully. Components instantiated in this manner support all of the usual dependency injection features.

background_worker.py

Application Initialization Hooks

@PreInit, @Init and @PostInit hooks are provided for running one-off tasks at startup and are invoked identically to background workers. These are, however, required to exit before the application can start.

app_init_hooks.py

  • PreInit is invoked right after the service locator and application properties are configured.
  • Init is invoked after initializing the routing table. At this stage, the application is in a coherent state.
  • PostInit is invoked after starting background workers and scheduled tasks. No further initialization task is left to be done.

Scheduled Tasks

One-off background tasks can be scheduled over a longer period of time using scheduled tasks. The @Scheduled annotation takes either a "cron" or "every" parameter.

  • cron : Takes a cron-style string.
  • every: Takes a Duration enum. (Duration.SECOND, Duration.MINUTE, Duration.HOUR, Duration.DAY)
  • start : Optional. Specifies a start time before which the task will not be run.

scheduled.py