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
46 47 48 49 50 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 46 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 26 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 16 def self.hydra_opts @hydra_opts ||= { followlocation: true, maxredirs: DiasporaFederation.http_redirect_limit, timeout: DiasporaFederation.http_timeout, method: :post, verbose: DiasporaFederation.http_verbose, cainfo: DiasporaFederation., forbid_reuse: true } end |
.json_headers ⇒ Object
35 36 37 38 39 40 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 35 def self.json_headers @json_headers ||= { "Content-Type" => "application/json", "User-Agent" => DiasporaFederation.http_user_agent } end |
.xml_headers ⇒ Object
28 29 30 31 32 33 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 28 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
62 63 64 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 62 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
55 56 57 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 55 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
68 69 70 71 |
# File 'lib/diaspora_federation/federation/sender/hydra_wrapper.rb', line 68 def send hydra.run @urls_to_retry end |