Class: DataSink::Client
- Inherits:
-
Object
- Object
- DataSink::Client
- Defined in:
- lib/data_sink/client.rb
Constant Summary collapse
- DEFAULTS =
{ url: '', endpoint: '/archives', retry_max: 2, retry_interval: 0.1, retry_backoff_factor: 2, adapter: :excon, read_timeout: 5, open_timeout: 5, }.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(stream_id, body) ⇒ Object
- #post_gzipped(stream_id, body) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 23 |
# File 'lib/data_sink/client.rb', line 18 def initialize(={}) = DEFAULTS.merge() user = .fetch(:user) pass = .fetch(:pass) @client = [:client] || create_client(user, pass) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
16 17 18 |
# File 'lib/data_sink/client.rb', line 16 def client @client end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/data_sink/client.rb', line 16 def end |
Instance Method Details
#post(stream_id, body) ⇒ Object
25 26 27 |
# File 'lib/data_sink/client.rb', line 25 def post(stream_id, body) post_gzipped(stream_id, gzip(body)) end |
#post_gzipped(stream_id, body) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/data_sink/client.rb', line 29 def post_gzipped(stream_id, body) client.post do |req| req.url endpoint(stream_id) req.body = body end end |