Class: DiasporaFederation::Federation::Sender::HydraWrapper
- Inherits:
-
Object
- Object
- DiasporaFederation::Federation::Sender::HydraWrapper
- Includes:
- Logging
- Defined in:
- lib/diaspora_federation/federation/sender/hydra_wrapper.rb
Overview
A wrapper for [Typhoeus::Hydra]
Uses parallel http requests to send out the salmon-messages
Class Method Summary collapse
-
.hydra_opts ⇒ Hash
Hydra default opts.
- .json_headers ⇒ Object
- .xml_headers ⇒ Object
Instance Method Summary collapse
-
#initialize(sender_id, obj_str) ⇒ HydraWrapper
constructor
Create a new instance for a message.
-
#insert_enc_magic_env_request(url, json) ⇒ Object
Prepares and inserts a private encrypted MagicEnvelope job into the hydra queue.
-
#insert_magic_env_request(url, xml) ⇒ Object
Prepares and inserts a public MagicEnvelope job into the hydra queue.
-
#send ⇒ Array<String>
Sends all queued messages.
Methods included from Logging
Constructor Details
#initialize(sender_id, obj_str) ⇒ HydraWrapper
Create a new instance for a message
45 46 47 48 49 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 45 def initialize(sender_id, obj_str) @sender_id = sender_id @obj_str = obj_str @urls_to_retry = [] end |
Class Method Details
.hydra_opts ⇒ Hash
Hydra default opts
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 16 def self.hydra_opts @hydra_opts ||= { followlocation: false, timeout: DiasporaFederation.http_timeout, method: :post, verbose: DiasporaFederation.http_verbose, cainfo: DiasporaFederation., forbid_reuse: true } end |
.json_headers ⇒ Object
34 35 36 37 38 39 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 34 def self.json_headers @json_headers ||= { "Content-Type" => "application/json", "User-Agent" => DiasporaFederation.http_user_agent } end |
.xml_headers ⇒ Object
27 28 29 30 31 32 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 27 def self.xml_headers @xml_headers ||= { "Content-Type" => "application/magic-envelope+xml", "User-Agent" => DiasporaFederation.http_user_agent } end |
Instance Method Details
#insert_enc_magic_env_request(url, json) ⇒ Object
Prepares and inserts a private encrypted MagicEnvelope job into the hydra queue
61 62 63 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 61 def insert_enc_magic_env_request(url, json) insert_job(url, HydraWrapper.hydra_opts.merge(body: json, headers: HydraWrapper.json_headers)) end |
#insert_magic_env_request(url, xml) ⇒ Object
Prepares and inserts a public MagicEnvelope job into the hydra queue
54 55 56 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 54 def insert_magic_env_request(url, xml) insert_job(url, HydraWrapper.hydra_opts.merge(body: xml, headers: HydraWrapper.xml_headers)) end |
#send ⇒ Array<String>
Sends all queued messages
67 68 69 70 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 67 def send hydra.run @urls_to_retry end |