Class: Frenchy::Client
- Inherits:
-
Object
- Object
- Frenchy::Client
- Defined in:
- lib/frenchy/client.rb
Instance Method Summary collapse
- #delete(path, params) ⇒ Object
-
#get(path, params) ⇒ Object
Issue a get request with the given path and query parameters.
-
#initialize(options = {}) ⇒ Client
constructor
Create a new client instance.
-
#post(path, params) ⇒ Object
Issue a non-retryable request with the given path and query parameters.
- #put(path, params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Create a new client instance
8 9 10 11 12 13 14 |
# File 'lib/frenchy/client.rb', line 8 def initialize(={}) .symbolize_keys! @host = .delete(:host) || "http://127.0.0.1:8080" @timeout = .delete(:timeout) || 60 @retries = .delete(:retries) || 0 end |
Instance Method Details
#delete(path, params) ⇒ Object
36 |
# File 'lib/frenchy/client.rb', line 36 def delete(path, params); perform(:delete, path, params); end |
#get(path, params) ⇒ Object
Issue a get request with the given path and query parameters
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/frenchy/client.rb', line 17 def get(path, params) try = 0 error = nil while try <= @retries begin return perform(:get, path, params) rescue Frenchy::ServerError, Frenchy::InvalidResponse => error sleep (0.35 * (try*try)) try += 1 end end raise error end |
#post(path, params) ⇒ Object
Issue a non-retryable request with the given path and query parameters
34 |
# File 'lib/frenchy/client.rb', line 34 def post(path, params); perform(:post, path, params); end |
#put(path, params) ⇒ Object
35 |
# File 'lib/frenchy/client.rb', line 35 def put(path, params); perform(:put, path, params); end |