This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-03-03
Channels
- # announcements (3)
- # babashka (29)
- # beginners (95)
- # calva (109)
- # cider (16)
- # clj-kondo (6)
- # cljdoc (2)
- # cljsrn (2)
- # cljtogether (1)
- # clojure (85)
- # clojure-europe (26)
- # clojure-india (1)
- # clojure-seattle (1)
- # clojure-uk (6)
- # clojurescript (14)
- # conjure (4)
- # cursive (8)
- # datomic (6)
- # emacs (21)
- # events (1)
- # figwheel-main (5)
- # fulcro (11)
- # graalvm (32)
- # graphql (1)
- # holy-lambda (7)
- # humbleui (7)
- # jobs (3)
- # membrane (8)
- # nextjournal (31)
- # off-topic (29)
- # pathom (14)
- # polylith (6)
- # portal (16)
- # practicalli (4)
- # reitit (17)
- # releases (1)
- # remote-jobs (2)
- # ring (4)
- # sci (20)
- # shadow-cljs (24)
- # sql (1)
- # vim (12)
- # xtdb (3)
Could anyone recommend a scheduling library for #babashka? I like the look of @jarohen's chime https://github.com/jarohen/chime but I get the following error
Could not find /home/vimuser/.deps.clj/1.10.3.1040/ClojureTools/clojure-tools-1.10.3.1040.jar
Downloading tools jar from to /home/vimuser/.deps.clj/1.10.3.1040/ClojureTools
Downloading: org/clojure/clojure/1.10.3/clojure-1.10.3.pom from central
Downloading: org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.pom from central
Downloading: org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.pom from central
Downloading: org/clojure/pom.contrib/0.3.0/pom.contrib-0.3.0.pom from central
Downloading: jarohen/chime/0.3.3/chime-0.3.3.pom from clojars
Downloading: org/clojure/tools.logging/1.0.0/tools.logging-1.0.0.pom from central
Downloading: org/clojure/pom.contrib/0.2.2/pom.contrib-0.2.2.pom from central
Downloading: org/clojure/clojure/1.10.3/clojure-1.10.3.jar from central
Downloading: org/clojure/tools.logging/1.0.0/tools.logging-1.0.0.jar from central
Downloading: org/clojure/core.specs.alpha/0.2.56/core.specs.alpha-0.2.56.jar from central
Downloading: org/clojure/spec.alpha/0.2.194/spec.alpha-0.2.194.jar from central
Downloading: jarohen/chime/0.3.3/chime-0.3.3.jar from clojars
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Unable to resolve classname: clojure.lang.IBlockingDeref
Location: chime/core.clj:4:3
----- Context ------------------------------------------------------------------
1: (ns chime.core
2: "Lightweight scheduling library."
3: (:require [clojure.tools.logging :as log])
4: (:import (clojure.lang IDeref IBlockingDeref IPending)
^--- Unable to resolve classname: clojure.lang.IBlockingDeref
5: (java.time ZonedDateTime Instant Clock)
6: (java.time.temporal ChronoUnit TemporalAmount)
7: (java.util Date)
8: (java.util.concurrent Executors ScheduledExecutorService ThreadFactory TimeUnit)
9: (java.lang AutoCloseable Thread$UncaughtExceptionHandler)))
----- Stack trace --------------------------------------------------------------
chime.core - chime/core.clj:4:3
The use case is as part of https://github.com/xlfe/radiale. The concept is the radiale babashka script runs as a service 24/7 (partially because as a home automation system, it has to manage state 24/7 - eg, sensor detects something, do something else) but I'd also like to be able to set timed actions too (eg. for example I want to turn on a light at the same time each day). So I'm looking for a scheduler that is happy within babashka. I could find a python one and interact with it through the pod framework, but I'm trying to keep as much in Clojure as possible (and chime looks nice!).,,
I think you could maybe rewrite chime in such a way that bb is happy with it. The problem is that (currently) bb can only reify
pre-selected java interface(s), so this won't work: https://github.com/jarohen/chime/blob/fa0b6e8c0f68e6d6134aee6ba9eb2ce032ba65b0/src/chime/core.clj#L117
But if you could rewrite that using functions, that would work just fine.
This seems like something that could work: https://github.com/overtone/at-at/blob/master/src/overtone/at_at.clj Given that all the Java classes are in bb.
Thanks - at-at looks like it would do too. Yes I get
----- Error --------------------------------------------------------------------
Type: java.lang.Exception
Message: Unable to resolve classname: java.util.concurrent.ScheduledThreadPoolExecutor
Location: overtone/at_at.clj:2:3
Hmm. I don't see how cron jobs would work, without some kind of message bus? Because my babashka script is long-running, rather than being started each time
Yeah. I think a python scheduler via the pod interface would be better than shell and cron!
I made a branch at-at
where I added the necessary classes. Let's see how much binary size it adds. You can download the binaries from #babashka-circleci-builds to try out if this works.
40kb is coming from java.text.SimpleDateFormat
which I resisted to add for a long time since java.time
is the recommend way, but it has come up so many times now that I will just go ahead and add it ;)
at-at, a Clojure scheduling library, will become bb-compatible in the next release: https://twitter.com/borkdude/status/1499338195963678720
Does it mean these bits will be available in bb
https://github.com/overtone/at-at/blob/master/src/overtone/at_at.clj#L2 right?
Are there any examples of babashka being used as a pandoc filter? https://pandoc.org/filters.html