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

sidekiq-sync

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sidekiq-sync

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

sidekiq-sync

Adds perform_sync to Sidekiq to get the return value from perform while still executing through Sidekiq (distributed workers!). Internally it stores the result in a unique queue that is polled.

install

gem install 'sidekiq-sync'

usage

class HardWorker
  include Sidekiq::Sync::Worker

  def perform(how_hard="super hard", how_long=1)
    puts "working #{how_hard}"
    sleep how_long
    "I worked #{how_hard}"
  end
end

puts HardWorker.perform_sync("really hard")
# outputs "I worked really hard"

puts HardWorker.perform_async("really hard")
# outputs the sidekiq job..

options = Sidekiq::Sync::Options.new(timeout: 3)
puts HardWorker.perform_sync(options, "really hard", 4)
# times out in 3 seconds and raises Sidekiq::Sync::TimeoutError

options = Sidekiq::Sync::Options.new(timeout: 3, raise: false)
puts HardWorker.perform_sync(options, "really hard", 4)
# times out in 3 seconds, returns nil, does not raise

options = Sidekiq::Sync::Options.new(timeout: 3, raise: false)
puts HardWorker.perform_sync(options, "really hard", 4)
# times out in 3 seconds, returns nil, does not raise

options = Sidekiq::Sync::Options.new(timeout: 3, raise: false)
puts HardWorker.perform_sync("really hard", options, 4)
# options can be wherever you wish (still sleeps 4, timeouts in 3 and does not raise)

FAQs

Package last updated on 02 Jan 2019

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