require 'faraday' require 'json' require 'notification_services/models' require 'resque' module NotificationServices module Workers # Takes our notification structure, and will basically hand it off to any # web hook that's been registered for it. class WebhookNotifier @queue = :notification_services def self.perform(notification) triggers = Models::Triggers.dataset.where(trigger: notification['trigger']).all triggers.each do |trigger| url = URI.parse(trigger.webhook.url) conn = Faraday.new(url: url) do |c| faraday.adapter Faraday.default_adapter end conn.post url.path do |request| request.headers['Content-Type'] = 'application/json' request.body = notification.to_json end end end end end end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 13972 | tjuricek |
Removing old microservice implementations. The system is now mostly a monolith. Eventually there will be a websocket service. |
||
#3 | 13689 | tjuricek | Switch from Resque to Sidekiq. | ||
#2 | 13469 | tjuricek |
Initial implementation of change-commit notification services. Set up a new database just for storing webhook configuration for the notification services. It uses the stable version of Resque, which needs to be evaluated in more detail. This should be easier for an admin to monitor than something like Sidekiq, but performance evaluation needs to happen before production release. No automated tests yet, that will rely upon a Phoenix notification mechanism existing first. |
||
#1 | 13468 | tjuricek | Set up resque worker that will trigger web hooks in the background. |