New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sidekiq-expiring-jobs

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sidekiq-expiring-jobs

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

SidekiqExpiringJobs

Build Status

Support for Sidekiq jobs which expire after a certain length of time. Jobs that are set to expire can run as long as they want, but an expiring job must start executing before the expiration time.

Note: Sidekiq Pro has this feature, so please consider upgrading if you can.

Use Cases

  1. Perhaps you want to expire a cache which has a TTL of 30 minutes with a Sidekiq job. If the job doesn't process successfully within 30 minutes, there's no point in executing the job.
  2. You use a Sidekiq job to send a daily digest email. If the job doesn't execute within 24 hours, perhaps you want to skip that day as the user might only care about the latest digest.
  3. You enqueue periodically a Sidekiq job to do some task. If the job doesn't execute before the next period begins, you may skip that job as the newly enqueued job will do the task.

Requirements

  • Ruby 2.7+
  • Sidekiq 6.0+

Installation

Add this line to your application's Gemfile:

gem 'sidekiq-expiring-jobs'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sidekiq-expiring-jobs

Defining Expiration

Statically:

class SomeJob
  include Sidekiq::Job
  sidekiq_options expires_in: 1.hour
  ...
end

Dynamically, per job:

SomeJob.set(expires_in: 1.day).perform_async(...)

expires_in must be a relative time, not an absolute timestamp.

Expiration knows about scheduled jobs: schedule a job to run two hours from now with a one hour expiration and it will expire three hours from now.

Configuration

You can override the following default options:

# A callback that is called when the job is expired.
# Accepts a job hash as an argument.
SidekiqExpiringJobs.expiration_callback = ->(job) {}

Development

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fatkodima/sidekiq-expiring-jobs.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 14 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc