mirror of
https://github.com/plashchynski/crono.git
synced 2026-03-17 23:14:14 +01:00
document how to schedule jobs with arguments
This commit is contained in:
11
README.md
11
README.md
@@ -61,11 +61,11 @@ class TestJob < ActiveJob::Base
|
||||
end
|
||||
```
|
||||
|
||||
The ActiveJob jobs is convenient because you can use one job in both periodic and enqueued ways. But Active Job is not required. Any class can be used as a crono job if it implements a method `perform` without arguments:
|
||||
The ActiveJob jobs is convenient because you can use one job in both periodic and enqueued ways. But Active Job is not required. Any class can be used as a crono job if it implements a method `perform`:
|
||||
|
||||
```ruby
|
||||
class TestJob # This is not an Active Job job, but pretty legal Crono job.
|
||||
def perform
|
||||
def perform(*args)
|
||||
# put you scheduled code here
|
||||
# Comments.deleted.clean_up...
|
||||
end
|
||||
@@ -124,6 +124,13 @@ The `at` can be a Hash:
|
||||
Crono.perform(TestJob).every 1.day, at: {hour: 12, min: 15}
|
||||
```
|
||||
|
||||
You can schedule a job with arguments, which can contain objects that can be
|
||||
serialized using JSON.generate
|
||||
|
||||
```ruby
|
||||
Crono.perform(TestJob, 'some', 'args').every 1.day, at: {hour: 12, min: 15}
|
||||
```
|
||||
|
||||
#### Run daemon
|
||||
|
||||
To run Crono daemon, in your Rails project root directory:
|
||||
|
||||
Reference in New Issue
Block a user