Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
resque-unique_in_queue
Advanced tools
Project | Resque::UniqueInQueue |
---|---|
gem name | resque-unique_in_queue |
license | |
download rank | |
version | |
dependencies | |
continuous integration | |
test coverage | |
maintainability | |
code triage | |
homepage | on Github.com, on Railsbling.com |
documentation | on RDoc.info |
Spread | 🌍 🌎 🌏, 🍚, ➕, 👼, 🐛, :shipit:, |
Resque::UniqueInQueue is a resque plugin to add unique jobs to resque.
It is a re-write of resque_solo, which is a fork of resque-loner.
It requires resque 1.25 and works with ruby 2.0 and later.
It removes the dependency on Resque::Helpers
, which is deprecated for resque 2.0.
Add the gem to your Gemfile:
gem 'resque-unique_in_queue'
resque-unique_in_queue
utilizes 3 class instance variables that can be set
in your Jobs, in addition to the standard @queue
. Here they are, with their
default values:
@lock_after_execution_period = 0
@ttl = -1
@unique_in_queue_key_base = 'r-uiq'.freeze
The last one, in normal circumstances, shouldn't be set as different per class, or uniqueness cleanup becomes more difficult.
It should be set only once, globally:
Resque::UniqueInQueue.configuration.unique_in_queue_key_base = 'my-custom'
class UpdateCat
include Resque::Plugins::UniqueInQueue
@queue = :cats
def self.perform(cat_id)
# do something
end
end
If you attempt to queue a unique job multiple times, it is ignored:
Resque.enqueue UpdateCat, 1
=> true
Resque.enqueue UpdateCat, 1
=> nil
Resque.enqueue UpdateCat, 1
=> nil
Resque.size :cats
=> 1
Resque.enqueued? UpdateCat, 1
=> true
Resque.enqueued_in? :dogs, UpdateCat, 1
=> false
lock_after_execution_period
By default, lock_after_execution_period is 0 and enqueued?
becomes false as soon as the job
is being worked on.
The lock_after_execution_period
setting can be used to delay when the unique job key is deleted
(i.e. when enqueued?
becomes false
). For example, if you have a long-running unique job that
takes around 10 seconds, and you don't want to requeue another job until you are sure it is done,
you could set lock_after_execution_period = 20
. Or if you never want to run a long running
job more than once per minute, set lock_after_execution_period = 60
.
class UpdateCat
include Resque::Plugins::UniqueInQueue
@queue = :cats
@lock_after_execution_period = 20
def self.perform(cat_id)
# do something
end
end
Preventing jobs with matching signatures from being queued, and they never get dequeued because there is no actual corresponding job to dequeue.
How to deal?
Option: Rampage
# Delete *all* queued jobs in the queue, and
# delete *all* unqueness keys for the queue.
Redis.remove_queue('queue_name')
Option: Butterfly
# Delete *no* queued jobs at all, and
# delete *all* unqueness keys for the queue (might then allow duplicates).
Resque::UniqueInQueue::Queue.cleanup('queue_name')
Bug reports and pull requests are welcome on GitHub at https://github.com/pboling/resque-unique_in_queue. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)Everyone interacting in the Resque::Plugins::UniqueInQueue project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.
As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.
For example:
spec.add_dependency 'resque-unique_in_queue', '~> 1.0'
FAQs
Unknown package
We found that resque-unique_in_queue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.