Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

duct-framework/scheduler.simple

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Duct scheduler.simple Build Status

Integrant methods for running functions periodically in a thread pool. Part of the Duct framework, but can be used in any application that uses Integrant.

Installation

Add the following dependency to your deps.edn file:

org.duct-framework/scheduler.simple {:mvn/version "0.2.1"}

Or to your Leiningen project file:

[org.duct-framework/server.http.jetty "0.2.1"]

Usage

The scheduler runs jobs, which are zero-argument functions, at periodic intervals. A configuration might look something like this:

{:duct.scheduler/simple
 {:jobs [{:interval 60   :run #ig/ref :example.job/every-minute}
         {:interval 3600 :run #ig/ref :example.job/every-hour]}

 :example.job/every-minute {}
 :example.job/every-hour   {}}

Where the example jobs are defined:

(require '[integrant.core :as ig])

(defmethod ig/init-key :example.job/every-minute [_ _]
  #(println "A minute passed."))

(defmethod ig/init-key :example.job/every-hour [_ _]
  #(println "An hour passed."))

The :duct.schedule/simple key takes a collection of :jobs, and optionally the :thread-pool-size, which defaults to 32.

Jobs are maps that have three keys:

  • :delay (optional) - how long in seconds to delay before the first job
  • :interval - how long in seconds between the start of each job
  • :run - a zero-argument function run at each interval

This scheduler isn't suitable for more complex cron-like scheduling, but is useful if you just want to periodically run cleanup, indexing or other processing scripts at regular intervals.

License

Copyright © 2025 James Reeves

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.