quantum-elixir / quantum-core

:watch: Cron-like job scheduler for Elixir
https://hexdocs.pm/quantum/
Apache License 2.0
2.32k stars 148 forks source link

Trigger Jobs Manually #452

Closed tanweerdev closed 4 years ago

tanweerdev commented 4 years ago

something like

    |> Quantum.Job.set_name(:test)
    |> Quantum.Job.set_schedule(:asap or :now)
    |> Quantum.Job.set_task(fn ->
      IO.puts("#{Timex.now()} - first hello")
    end)
    |> add_job()

https://github.com/quantum-elixir/quantum-core/issues/392

maennchen commented 4 years ago

Currently this is not possible.

Why would you want to do this via quantum? Wouldn‘t Job.async or similar work for you?

tanweerdev commented 4 years ago

@maennchen Job.async is part of some library? which one?

maennchen commented 4 years ago

@tanweerdev Sorry, I meant Task.async:

https://hexdocs.pm/elixir/Task.html#async/3

tanweerdev commented 4 years ago

I am getting this warning and timeout inside a channel event handle_in/3 [warn] Phoenix.Channel.Server #PID<0.765.0> received unexpected message in handle_info/2: {#Reference<0.4027534044.3015442433.81688>, {:ok, %ChannelConnection{__meta__: #Ecto.Schema.Metadata<:loaded, "channel_connections">, ...updated_at: ~N[2020-08-24 11:49:10.057884]}}} and the documentation says Starts a task that must be awaited on. but I dont want to wait for this task to finish. This should continue totally independently...

tanweerdev commented 4 years ago

@maennchen I mean now is also a timestamp and quantum should be able to handle it

maennchen commented 4 years ago

@tanweerdev You can also run it completely independently with Task. Have a look at its functions.

Quantum currently only works with cron expressions. Opening that functionality up for different methods would be a long time goal (#268). Just adding a single atom as a schedule is however not a direction I‘d lile to go.

Quantum is about scheduling tasks i. intervals and i. the future. For right now there’s a lot of other options.

ericdude4 commented 4 years ago

Quantum handles event overlap, so it would be nice to be able to call MyApp.Scheduler.run_job(:my_job) and then have the overlap prevention stop this "one-off" job from overlapping with the normal job schedule.

maennchen commented 4 years ago

@ericdude4 That sounds like a reasonable enhancement. A PR would be very welcome.

ericdude4 commented 4 years ago

@maennchen I would be happy to

maennchen commented 4 years ago

@ericdude4 Great! If you have any questions, I'll be happy to provide some guidance. (Here or on #quantum in the elixir slack.)

maennchen commented 4 years ago

Released as v3.3.0