Slackiq = Slack + Sidekiq
Slackiq (pronounced slack-kick) integrates Slack and Sidekiq so that you can have vital information about your Sidekiq jobs sent directly to your team's Slack.
Add this line to your Gemfile:
gem 'slackiq'Then run:
bundle installFirst, set up any number of Slack Incoming Webhooks from your Slack.
Then, you only need to call the configure method when your application launches to configure all of the webhooks to which you want to post. If you're using Rails, create an initializer at config/initializers/slackiq.rb. Here's an example:
Slackiq.configure( web_scrapes: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/lknsaHHA2323KKDKND',
data_processing: 'https://hooks.slack.com/services/HA298HF2/ALSKF2451/H24dLKAHD22423'):web_scrapes and data_processing are examples of keys. Use whatever keys you want.
You can call notify to send a nicely-formatted notification to your Slack. You can call notify
on_success or on_complete callback (not available on regular Sidekiq--only Pro)bid to the perform method of the workerThe notify method has a single Hash parameter. Here are the keys and values in the Hash:
:webhook_name The name of the webhook (Symbol) that you configured (eg. :web_scrapes or :data_processing):title The title of the notification (String):status An instance of Sidekiq::Batch::StatusIf you haven't used batches with Sidekiq Pro before, read this first.
Here's an example showing how you would use Slackiq to send a notification to your Slack when your Sidekiq batch completes:
class WebScraper
class URL.count.to_s,
'Servers' => "#{Server.active_count} active, #{Server.inactive_count} inactive")
end
endNote that in this case, 'Total URLs in DB' and 'Servers' are custom fields that will also appear in Slack!
No prob. Just:
Slackiq.message('Server 5 is overloaded!', webhook_name: :data_processing)Bug reports and pull requests are welcome on GitHub at https://github.com/MightySignal/slackiq. 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.
The gem is available as open source under the terms of the MIT License.
https://blog.mightysignal.com/slackiq-a-ruby-gem-that-connects-slack-and-sidekiq-a2308c1974b7
暂无开放 Issues,或尚未同步最近议题。