Code Monkey home page Code Monkey logo

take2's People

Contributors

dependabot[bot] avatar evnomad avatar shved270189 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

shved270189

take2's Issues

Ability to set configuration on method call level

Currently the take2 configurations are class level.
So in order to implement different set of defaults for two different implementations in same class they must be re-declaired.

I would like to be able to set defaults per method call:

class Service
  include Take2
  
  # use class defaults
  def call
    call_api_with_retry do
      # code ..
    end
  end
  
 # use method defaults
  def perform
    call_api_with_retry(config_hash) do
      # more code..
    end
  end

end 

Add ability to define logger

I want to be able to define custom logger for the retry attempts output.
For example:

class Service
  include Take2

  logger Logger.new('take2.log')
  on_retry proc { |error, tries| self.logger.info "#{self.name} - Retrying.. #{tries} of #{self.retriable_configuration[:retries]} (#{error})" }

end

Errors defined with retriable_errors helper overwrites the defaults instead of appending

Take2.configure do |config|
  config.retries    = 3
  config.retriable  = [
      Net::HTTPServerError,
      Net::HTTPServerException,
      Net::HTTPRetriableError
  ].freeze
end
class Service
  include Take2
  
  class CustomError < StandardError; end
  
  retriable_errors CustomError

end
Service.retriable_configuration
=> {:retries=>3, :retriable=>[Service::CustomError] ....

Desired behaviour:

Service.retriable_configuration
=> {:retries=>3, 
    :retriable=>[
    Net::HTTPServerError,
    Net::HTTPServerException,
    Net::HTTPRetriableError,
    Service::CustomError
] ...

Unable to reset to decimal or nil configurations

Unable to reset time_to_sleep to decimal or nil.

Expected:

Take2.reset(time_to_sleep: 1.1)
=> #<Take2::Configuration:0x007f9ac0076388 @retries=1, @retriable=[Net::HTTPServerError, Net::HTTPServerException, Net::HTTPRetriableError, Errno::ECONNRESET, IOError], @retry_proc=#<Proc:0x007f9ac00762c0@/Users/antonmagids/.rvm/gems/ruby-2.4.1/gems/take2-0.0.2/lib/take2/configuration.rb:16>, @retry_condition_proc=#<Proc:0x007f9ac0076298@/Users/antonmagids/.rvm/gems/ruby-2.4.1/gems/take2-0.0.2/lib/take2/configuration.rb:17>, @time_to_sleep=1.1>

Take2.reset(time_to_sleep: nil)
=> #<Take2::Configuration:0x007f9ac0076388 @retries=1, @retriable=[Net::HTTPServerError, Net::HTTPServerException, Net::HTTPRetriableError, Errno::ECONNRESET, IOError], @retry_proc=#<Proc:0x007f9ac00762c0@/Users/antonmagids/.rvm/gems/ruby-2.4.1/gems/take2-0.0.2/lib/take2/configuration.rb:16>, @retry_condition_proc=#<Proc:0x007f9ac0076298@/Users/antonmagids/.rvm/gems/ruby-2.4.1/gems/take2-0.0.2/lib/take2/configuration.rb:17>, @time_to_sleep=nil>

Actual:

Take2.reset(time_to_sleep: 1.1)
=> #ArgumentError: time_to_sleep must be positive integer

Take2.reset(time_to_sleep: nil)
=> #ArgumentError: time_to_sleep must be positive integer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.