Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

migratiq

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

migratiq

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Migratiq

Migrate your scheduled sidekiq jobs when their arguements change. :tada:

After a deploy, if the number of arguements on a worker has changed those workers tend to fail unless you delete them manually now you can either specify a migration plan for a particular number of arguments i.e.

class HardWorker
  include Migratiq

  def perform(a, b)
    # Do work here...
  end

  migrate_by(arity: 5) do |a, b, c, d, e|
    [b, a]
  end
end

pry> HardWorker.migrate!

or remove all jobs that don't match the current interface

class HardWorker
  include Migratiq

  def perform(a, b)
    # Do work here...
  end
end

pry> HardWorker.migrate!(delete: true)

Installation

Add this line to your application's Gemfile:

gem 'migratiq'

And then execute:

$ bundle

Or install it yourself as:

$ gem install migratiq

Usage

Say your current worker looks something like,

class HardWorker
  def perform(a, b, c, d)
    # Do work here...
  end
end

and you find that you no longer need to take arguments c and d. So now your worker looks like,

class HardWorker
  def perform(a, b)
    # Do work here...
  end
end

Now if you deploy this change and HardWorker has work that is already scheduled, all those jobs will fail.

if you aren't concerned about loosing that work, all you need to do is add migratiq and you can remove them all and clean up your logs

class HardWorker
  include 'migratiq'
  def perform(a, b)
    # Do work here...
  end
end

pry>HardWorker.migrate!(delete: true)

It will remove all the jobs that do not match the current arity of the perform function. However, if you don't want to loose your work, you can tell Migratiq how to migrate the worker params

class HardWorker
  include Migratiq

  def perform(a, b)

  end

  migrate_by(arity: 4) do |a, b, c, d|
    [b, a]
  end
end

pry> HardWorker.migrate!

This work will be rescheduled with the new arguements. if you also want to delete the old jobs you can add the delete: true flag on migrate.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rspec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

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 tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/HParker/migratiq.

FAQs

Package last updated on 03 Dec 2015

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