README.md in px-service-client-1.0.1 vs README.md in px-service-client-1.0.4

- old
+ new

@@ -22,12 +22,12 @@ ```ruby require 'px-service-client' class MyClient - include Px::Service::Client::::Caching - include Px::Service::Client::::CircuitBreaker + include Px::Service::Client::Caching + include Px::Service::Client::CircuitBreaker end ``` Features @@ -35,14 +35,14 @@ This gem includes several common features used in 500px service client libraries. The features are: -#### Px::Service::Client::::Caching +#### Px::Service::Client::Caching ```ruby -include Px::Service::Client::::Caching +include Px::Service::Client::Caching self.cache_client = Dalli::Client.new(...) self.cache_logger = Logger.new(STDOUT) # or Rails.logger, for example ``` @@ -53,45 +53,37 @@ to be refreshed probabilistically (rather than on every request). *first-resort* means that the cached value is always used, if present. Requests to the service are only made when the cached value is close to expiry. -#### Px::Service::Client::::CircuitBreaker +#### Px::Service::Client::CircuitBreaker ```ruby -def call_remote_service() ... - -circuit_method :call_remote_service - # Optional circuit_handler do |handler| handler.logger = Logger.new(STDOUT) handler.failure_threshold = 5 handler.failure_timeout = 5 handler.invocation_timeout = 10 handler.excluded_exceptions += [NotConsideredFailureException] end ``` -Provides a circuit breaker on the class, and turns the class into a singleton. Each method named using -`circuit_method` will be wrapped in a circuit breaker that will raise a `Px::Service::ServiceError` if the breaker -is open. The circuit will open on any exception from the wrapped method, or if the wrapped method -runs for longer than the `invocation_timeout`. +Adds a circuit breaker to the client. The circuit will open on any exception from the wrapped method, or if the request runs for longer than the `invocation_timeout`. -Note that `Px::Service::ServiceRequestError` exceptions do NOT trip the breaker, as these exceptions indicate an error -on the caller's part (e.g. an HTTP 4xx error). +Note that `Px::Service::ServiceRequestError` exceptions do NOT trip the breaker, as these exceptions indicate an error on the caller's part (e.g. an HTTP 4xx error). -The class is made a singleton using the standard `Singleton` module. Access to the class's methods should be done -using its `instance` class method (calls to `new` will fail). +Every instance of the class that includes the `CircuitBreaker` concern will share the same circuit state. You should therefore include `Px::Service::Client::CircuitBreaker` in the most-derived class that subclasses +`Px::Service::Client::Base` This module is based on (and uses) the [Circuit Breaker](https://github.com/wsargent/circuit_breaker) gem by Will Sargent. -#### Px::Service::Client::::ListResponse +#### Px::Service::Client::ListResponse ```ruby def get_something(page, page_size) response = JSON.parse(http_get("http://some/url?p=#{page}&l=#{page_size}")) - return Px::Service::Client::::ListResponse(page_size, response, "items") + return Px::Service::Client::ListResponse(page_size, response, "items") end ``` Wraps a deserialized response. A `ListResponse` implements the Ruby `Enumerable` module, as well