Open davejlong opened 7 years ago
We can support a cron-like interval format. We can even re-use some code from https://github.com/c-rack/quantum-elixir to support it.
Not so sure about the for
key though, seems to specific to the actual use-case you have.
What about supporting a then
macro?
job :notify_about_scrum, cron: "30 9 * * 1-5" do
broadcast! :scrum, %{text: "Time for scrum!"}
end |> then after: {15, :minutes} do
broadcast! :reset, %{text: "relax! scrum's over"}
end
We don't even have to provide an after
option, it can be a simple :timer.sleep
inside then
.
Oooo that's a cool syntax for it!
On Wed, Jun 28, 2017 at 6:53 PM Dimitrios Zorbas notifications@github.com wrote:
We can support a cron-like interval format. We can even re-use some code from https://github.com/c-rack/quantum-elixir to support it.
Not so sure about the for key though, seems to specific to the actual use-case you have. What about supporting a then macro?
job :notify_about_scrum, cron: "30 9 1-5" do broadcast! :scrum, %{text: "Time for scrum!"}end |> then after: {15, :minutes} do broadcast! :reset, %{text: "relax! scrum's over"}end
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kittoframework/kitto/issues/115#issuecomment-311814423, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKs1TJNju2R35mr3H_my5cUJg8D3GAtks5sItl6gaJpZM4OD84H .
@davejlong I was thinking about this, implementing a then
macro but it might be ambiguous as it could either mean:
I also think it might be more straightforward to use https://github.com/c-rack/quantum-elixir for cron-style scheduling in conjunction with Kitto jobs:
# File: config/config.exs
config :your_app, Sample.Scheduler,
jobs: [{"30 9 * * 1-5", {ScheduledTasks, :opsgenie, []}}]
defmodule ScheduledTasks do
import Kitto.Notifer, only: [broadcast!: 2]
def opsgenie do
broadcast! :opsgenie, %{alert: "Server is down"}
end
end
It might be worth it writing a wiki guide about this, to provide a working solution first.
Feature request for the ability to schedule jobs in a cron style schedule.
Example Use Case
Schedule to post a message in a Text widget every day:
The expected functionality would be that at 9:30 on Monday through Friday the message "Time for scrum!" would be broadcasted to the
:scrum
event. Thefor
key in the job setup would build a second job that would run 15 minutes later (9:45 Monday through Friday) that would clear the event from the cache allowing the text widget to go back to it's default value.