项目作者: qmfkdldks

项目描述 :
Create service object easily with circuit breaker pattern.
高级语言: Ruby
项目地址: git://github.com/qmfkdldks/make_serviceable.git
创建时间: 2019-02-07T15:53:29Z
项目社区:https://github.com/qmfkdldks/make_serviceable

开源协议:MIT License

下载


MakeServiceable

This gem will help you implement circuit breaker pattern to all services objects. Any unstable API should be protected by circuit breaker pattern. When API call fails so frequently, circuit will be opened and will skip the method directly to fail fast and get more resilient behaviour. After few seconds it will close circuit so method get called normaly.

Installation

Add this line to your application’s Gemfile:

  1. gem 'make_serviceable'

And then execute:

  1. $ bundle

Or install it yourself as:

  1. $ gem install make_serviceable

Usage

Following command will create new service object under app/services folder.

  1. $ bundle exec make_serviceable generate TestService

This is how service object looks like.

  1. class TestService
  2. include MakeServiceable
  3. # Pass ncessary parameters and then use it in #call
  4. def initialize()
  5. end
  6. # Set service name (optional). Default is class name
  7. # def service_name
  8. # end
  9. # Chage circuit behaviour here. Read documentation of circuitbox
  10. # def circuit_option
  11. # {}
  12. # end
  13. def call
  14. # Call any API call here. All failures are captured by circuit and it will be protected by circuit breaker pattern.
  15. end
  16. end

And you can call

  1. TestService.call()

Development

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/make_serviceable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the MakeServiceable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.