Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Threaded, easy to use scheduling and background job solution.
Schedules are managed by a watcher thread and enqueued as background jobs when they are due.
Background work is stored in a thread-safe Queue
and worked on by a pool of worker threads.
Add this line to your application's Gemfile:
gem 'threasy'
And then execute:
$ bundle
Or install it yourself as:
$ gem install threasy
Threasy.enqueue
# Use a block
Threasy.enqueue { puts "This will happen in the background" }
# Use an object that responds to `perform` or `call`
Threasy.enqueue MyJob.new(1,2,3)
Jobs are placed in a work queue. Worker threads are spun up to process jobs as the queue grows.
Threasy.schedule
Puts a job onto the schedule. Once the scheduler sees a job is due for processessing, it is enqueued into the work queue to be processed like any other job.
Available options:
:every
: number of seconds between repetition. Can be combined with :at
or :in
.:in
: number of seconds until job is (next) triggered.:at
: Time
job is (next) triggered.:times
: number of times to trigger job before removing it from the schedule.Example:
# Use a block
Threasy.schedule(:in => 5.minutes) { puts "In the background, 5 minutes from now" }
# Use an job object
Threasy.schedule(MyJob.new(1,2,3), every: 5.minutes)
Threasy.schedules
Returns the default instance of Threasy::Schedule
, which manages scheduled jobs.
Threasy.work
Returns the default instance of Threasy::Work
, which manages the work queue and worker threads.
Threasy.config
Returns the default instance of Threasy::Config
, which manages runtime configuration options.
Threasy.config
can also accept a block and will yield the Threasy::Config
instance.
Threasy.config do |c|
c.max_sleep = 5.minutes
c.max_overdue = 1.hour
c.max_workers = 8
end
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that threasy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.