Class: RivetCms::WebhookDeliveryJob
- Inherits:
-
ApplicationJob
- Object
- ActiveJob::Base
- ApplicationJob
- RivetCms::WebhookDeliveryJob
- Defined in:
- app/jobs/rivet_cms/webhook_delivery_job.rb
Overview
Basic CE webhook delivery: one POST, JSON body, short timeouts, no signing. Any failure (connection error or non-2xx response) raises, so retry behavior uniformly follows the host's queue adapter defaults.
Defined Under Namespace
Classes: DeliveryError
Constant Summary collapse
- OPEN_TIMEOUT =
5- READ_TIMEOUT =
10- WRITE_TIMEOUT =
10
Instance Method Summary collapse
Instance Method Details
#perform(url, payload) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/jobs/rivet_cms/webhook_delivery_job.rb', line 18 def perform(url, payload) uri = URI.parse(url) http = Net::HTTP.new(uri.hostname, uri.port) http.use_ssl = uri.scheme == "https" http.open_timeout = OPEN_TIMEOUT http.read_timeout = READ_TIMEOUT http.write_timeout = WRITE_TIMEOUT request = Net::HTTP::Post.new(uri.request_uri, "Content-Type" => "application/json", "User-Agent" => "RivetCMS/#{RivetCms::VERSION}") request.body = payload.to_json response = http.request(request) unless response.is_a?(Net::HTTPSuccess) raise DeliveryError, "webhook to #{uri.host} responded #{response.code}" end end |