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, add_newlines: true }.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, partition_key: nil) ⇒ Object
- #post_gzipped(stream_id, body, partition_key: nil) ⇒ Object
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
17 18 19 |
# File 'lib/data_sink/client.rb', line 17 def client @client end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
17 18 19 |
# File 'lib/data_sink/client.rb', line 17 def @options end |
Instance Method Details
#post(stream_id, body, partition_key: nil) ⇒ Object
26 27 28 |
# File 'lib/data_sink/client.rb', line 26 def post(stream_id, body, partition_key: nil) post_gzipped(stream_id, gzip(transform(body)), partition_key: partition_key) end |
#post_gzipped(stream_id, body, partition_key: nil) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/data_sink/client.rb', line 30 def post_gzipped(stream_id, body, partition_key: nil) client.post do |req| req.url endpoint(stream_id, partition_key) req.body = body end end |