brndnmtthws

brndnmtthws

Citrine - scheduled jobs for your Elixir app with cron syntax

I’d like to announce a new library I wrote recently for a project I’ve been working on. The library is called Citrine, it’s for managing and running scheduled jobs on an Erlang cluster as part of an existing application.

Summary: With Citrine you define a job, schedule it using cron syntax, and the library manages execution globally across the cluster to keep jobs running continuously. It’s designed to be used in stateless application environments such as Kubernetes.

# Create a job
job = %Citrine.Job{
  id: "my_job_id",
  schedule: "* * * * * *", # Run every second
  task: job_task,
  extended_syntax: true # Use extended cron syntax
}
# Start or update a job
MyApp.Scheduler.put_job(job)
# Terminate and delete a job
MyApp.Scheduler.delete_job(job)

Why I made this: I spent quite a bit of time looking into some of the existing libraries that existed, and none of them did exactly when I wanted, so I decided to build my own. It uses mnesia for state management, and mostly relies on Erlang primitives for everything. Thus, there are very few external dependencies (currently it only uses the crontab library, which itself has almost zero dependencies).

Some other thoughts: I followed convention over configuration with this library. As such, there aren’t many options to change, and the API interface itself really only has 3 function (put a job, delete a job, and list jobs).

Docs: https://hexdocs.pm/citrine/readme.html

Most Liked

brndnmtthws

brndnmtthws

Initially I was using Quantum, but I found that the global mode it came with was not working properly. The reasons are documented in this GitHub issue. To be fair, it looks like there’s been a lot of progress since I last used it.

I also looked into using the Horde CRDT library instead of mnesia, but I found it to be too buggy and unreliable. I spent a few days working on resolving the bugs in Horde (you can see my fork here if you want) but it was taking up too much time and I needed to focus on other things.

I ended up just writing a really small library to do exactly what I needed, and I decided to clean it up and open source it for anyone to use.

hauleth

hauleth

What are main differences between this and Quantum?

Where Next?

Popular in Libraries Top

tompave
Hello there, I would like to share a feature toggles library (AKA feature flags) I’ve been working on. The main package is FunWithFlags...
New
deadtrickster
I’ve just released stable versions of my Prometheus Elixir libs: Elixir client [docs]; Ecto collector [docs]; Plugs instrumenter/Export...
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
dbern
I’m excited to announce that TaxJar has developed and open-sourced DateTimeParser. We developed it because we found a need to parse user ...
New
michalmuskala
Another small library today. PersistentEts Hex: persistent_ets | Hex GitHub: GitHub - michalmuskala/persistent_ets Ets table backed by...
New
Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
Hal9000
Here is my first stab at this. README pasted below. https://github.com/Hal9000/elixir_random Comments and critiques are welcome. Th...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

Sub Categories:

We're in Beta

About us Mission Statement