· 1 min read
Screencast: Sidekiq
Downloads in verschiedenen Formaten:
Resourcen:
terminal
[bash]
brew install redis redis-server /usr/local/etc/redis.conf bundle exec sidekiq bundle exec sidekiq -q high,5 default [/bash]
Gemfile
[ruby] gem ‘sidekiq’ gem ‘sinatra’, require: false gem ‘slim’ [/ruby]
snippets_controller.rb
[ruby] PygmentsWorker.perform_async(@snippet.id) # PygmentsWorker.perform_in(1.hour, @snippet.id) [/ruby]
app/workers/pygments_worker.rb
[ruby]
class PygmentsWorker include Sidekiq::Worker sidekiq_options queue: “high” # sidekiq_options retry: false def perform(snippet_id) snippet = Snippet.find(snippet_id) uri = URI.parse(“http://pygments.appspot.com/”) request = Net::HTTP.post_form(uri, lang: snippet.language, code: snippet.plain_code) snippet.update_attribute(:highlighted_code, request.body) end end [/ruby]
routes.rb
[ruby]
require ‘sidekiq/web’ # … mount Sidekiq::Web, at: ‘/sidekiq’ [/ruby]