Class: Async::Polygon::Client
- Inherits:
-
Object
- Object
- Async::Polygon::Client
- Defined in:
- lib/async/polygon/client.rb
Instance Method Summary collapse
- #get(uri) ⇒ Object
-
#initialize(api_key: ENV['POLYGON_API_KEY'], basic: true) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(api_key: ENV['POLYGON_API_KEY'], basic: true) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/async/polygon/client.rb', line 8 def initialize(api_key: ENV['POLYGON_API_KEY'], basic: true) api_key.to_s.length == 32 \ or raise ArgumentError, 'API key required' set_pace basic @auth_headers = {'authorization' => "Bearer #{api_key}"} @client = Async::HTTP::Internet.new @request_semaphore = Async::Semaphore.new @reconnect_after @completion_semaphore = Async::Semaphore.new @reconnect_after @reset_mutex = Mutex.new end |
Instance Method Details
#get(uri) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/async/polygon/client.rb', line 19 def get(uri) ensure_client_readiness @request_semaphore.acquire @completion_semaphore.acquire do Sync do @client.get uri, @auth_headers end end end |