Class: HornOfPlenty::Adapters::Github::Client
- Inherits:
-
Object
- Object
- HornOfPlenty::Adapters::Github::Client
- Includes:
- Wisper::Publisher
- Defined in:
- lib/horn_of_plenty/adapters/github/client.rb
Constant Summary collapse
- RETRY_BACKOFF_MULTIPLIER =
3.5
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#token ⇒ Object
Returns the value of attribute token.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .configuration ⇒ Object
-
.pool ⇒ Object
rubocop:enable Metrics/LineLength.
Instance Method Summary collapse
-
#initialize(url: configuration.base_url, version: configuration.api_version, token: configuration.token, logger: configuration.logger) ⇒ Client
constructor
A new instance of Client.
-
#request(request, retries = 3, _retry_delay_in_ms = 1000) ⇒ Object
rubocop:disable Metrics/LineLength.
Constructor Details
#initialize(url: configuration.base_url, version: configuration.api_version, token: configuration.token, logger: configuration.logger) ⇒ Client
Returns a new instance of Client.
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 23 def initialize(url: configuration.base_url, version: configuration.api_version, token: configuration.token, logger: configuration.logger) self.url = url self.version = version self.token = token self.logger = logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
18 19 20 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 18 def logger @logger end |
#token ⇒ Object
Returns the value of attribute token.
18 19 20 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 18 def token @token end |
#url ⇒ Object
Returns the value of attribute url.
18 19 20 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 18 def url @url end |
#version ⇒ Object
Returns the value of attribute version.
18 19 20 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 18 def version @version end |
Class Method Details
.configuration ⇒ Object
58 59 60 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 58 def self.configuration Github::Configuration.instance end |
.pool ⇒ Object
rubocop:enable Metrics/LineLength
54 55 56 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 54 def self.pool @pool ||= ConnectionPool::Wrapper.new(size: 7, timeout: 20) { new } end |
Instance Method Details
#request(request, retries = 3, _retry_delay_in_ms = 1000) ⇒ Object
rubocop:disable Metrics/LineLength
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/horn_of_plenty/adapters/github/client.rb', line 35 def request(request, retries = 3, _retry_delay_in_ms = 1000) broadcast(:horn_of_plenty_request_sent, request.class.name, request.method, request.path, request.to_h, url, retries) response = connection.public_send(request.method, request.path, request.to_h) broadcast(:horn_of_plenty_response_received, response.class.name, request.method, request.path, response.body, url) request.response_class.parse(response) rescue Github::Errors => exception retries -= 1 broadcast(:horn_of_plenty_request_retried, exception, retries) retry if retries.positive? raise exception end |