Fork me on GitHub

Could anyone recommend a scheduling library for #babashka? I like the look of @jarohen's chime but I get the following error

Could not find /home/vimuser/.deps.clj/
Downloading tools jar from  to /home/vimuser/.deps.clj/
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 [ :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 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: But if you could rewrite that using functions, that would work just fine.


This seems like something that could work: Given that all the Java classes are in bb.


It seems that ScheduledThreadPoolExecutor is the most important one to add.


Another idea might be to use cron jobs directly


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


I mean, you could shell out to install cron jobs, but that might not be so nice.


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.


It seems the binary size growth is pretty reasonable.


thanks! that was quick 🙂


I'll give it a whirl 🙂


That's looking like a winner


only 106kb added 😂


did it work for you?


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 ;)


merged to master


🙂 thanks!


at-at, a Clojure scheduling library, will become bb-compatible in the next release:


yes. already available with:

bash <(curl ) --version 0.7.7-SNAPSHOT --dir .

🙌 1

Are there any examples of babashka being used as a pandoc filter?

😃 1