document how to schedule jobs with arguments

This commit is contained in:
Jannis Hübl
2016-01-14 10:23:46 +01:00
parent 89f3b9a8a1
commit 042228900f

View File

@@ -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: