classThirdPartyApiJobincludeCosmo::Job# At most 3 instances of this job run at once, cluster-wide.# Jobs that lose the race are NAK'd and redelivered after half of `duration`,# or after `retry_in` when set (e.g. limit: { duration: 30, concurrency: 3, retry_in: 5 }).
options limit: { duration: 30, concurrency: 3 }
endclassCrawlJobincludeCosmo::Job# Durations take seconds or strings such as "82m", "2h" or "1h22m" (also for limit retry_in).
options limit: { duration: "1h22m" }
endclassPerAccountSyncJobincludeCosmo::Job# Scope the cap per key instead of class-wide — e.g. one concurrent sync per account.
options limit: { duration: 30, concurrency: { to: 1, key: ->(account_id) { account_id } } }
defperform(account_id)
Account.find(account_id).sync!endend