Class: RudderAnalyticsSync::Request
- Inherits:
-
Object
- Object
- RudderAnalyticsSync::Request
- Defined in:
- lib/rudder_analytics_sync/request.rb
Constant Summary
Constants included from Constants
Constants::BASE_URL, Constants::DEFAULT_CONTEXT, Constants::DEFAULT_HEADERS, Constants::MAX_BATCH_SIZE, Constants::MAX_MESSAGE_SIZE
Instance Attribute Summary collapse
-
#data_plane_url ⇒ Object
readonly
Returns the value of attribute data_plane_url.
-
#error_handler ⇒ Object
readonly
Returns the value of attribute error_handler.
-
#gzip ⇒ Object
readonly
Returns the value of attribute gzip.
-
#http_options ⇒ Object
readonly
Returns the value of attribute http_options.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#stub ⇒ Object
readonly
Returns the value of attribute stub.
-
#write_key ⇒ Object
readonly
Returns the value of attribute write_key.
Instance Method Summary collapse
-
#initialize(client) ⇒ Request
constructor
rubocop:disable Metrics/AbcSize.
- #post(path, payload, headers: DEFAULT_HEADERS) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(client) ⇒ Request
rubocop:disable Metrics/AbcSize
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/rudder_analytics_sync/request.rb', line 15 def initialize(client) # rubocop:disable Metrics/AbcSize @write_key = client.config.write_key @data_plane_url = client.config.data_plane_url || BASE_URL @error_handler = client.config.on_error @stub = client.config.stub @logger = client.config.logger @http_options = client.config. @gzip = client.config.gzip.nil? ? true : client.config.gzip @retry = Retry.new(client.config) end |
Instance Attribute Details
#data_plane_url ⇒ Object (readonly)
Returns the value of attribute data_plane_url.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def data_plane_url @data_plane_url end |
#error_handler ⇒ Object (readonly)
Returns the value of attribute error_handler.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def error_handler @error_handler end |
#gzip ⇒ Object (readonly)
Returns the value of attribute gzip.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def gzip @gzip end |
#http_options ⇒ Object (readonly)
Returns the value of attribute http_options.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def @http_options end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def logger @logger end |
#stub ⇒ Object (readonly)
Returns the value of attribute stub.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def stub @stub end |
#write_key ⇒ Object (readonly)
Returns the value of attribute write_key.
13 14 15 |
# File 'lib/rudder_analytics_sync/request.rb', line 13 def write_key @write_key end |
Instance Method Details
#post(path, payload, headers: DEFAULT_HEADERS) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rudder_analytics_sync/request.rb', line 26 def post(path, payload, headers: DEFAULT_HEADERS) begin uri = URI(data_plane_url) return stub_post(path, payload) if stub payload, headers = encode(payload, headers) rescue StandardError => e return error_handler.call(nil, nil, e, nil) end execute_post(uri, path, payload, headers) end |