assaf / vanity

Experiment Driven Development for Ruby
http://vanity.labnotes.org
MIT License
1.55k stars 269 forks source link

Don't throw errors if datastore was not initialised correctly #325

Closed kirhgoff closed 7 years ago

kirhgoff commented 7 years ago

We are trying to make our service (which uses Vanity) to work in case Redis storage is down. We added initializer to catch datastore errors:

Vanity.configure do |config|
  config.failover_on_datastore_error = true
  config.on_datastore_error =  Proc.new do |error, klass, method, arguments|
    Rails.logger.error("Vanity error: #{error} called by #{klass.inspect}, method #{method.inspect} with arguments #{arguments}")
  end
end

and it does catch the errors, though application still experiences 500 errors because lines of code like:

Vanity.playground.participant_info(vanity_identity) 

still throw errors.

We tried to use method Vanity.playground.connected? to check for Vanity state, but it returns true even if datastore errors were reported before the call.

What is a recommended method to use Vanity that it is silent if datastore error has happened? How to check that Vanity is not backed by datastore and cannot be used?

phillbaker commented 7 years ago

Hm, the Redis adapter does wrap calls to catch exceptions. What version of Vanity are you using? Can you post a stack trace of an exception?

On Thu, Jun 8, 2017 at 11:41 PM Kirill Lastovirya notifications@github.com wrote:

We are trying to make our service (which uses Vanity) to work in case Redis storage is down. We added initializer to catch datastore errors:

Vanity.configure do |config| config.failover_on_datastore_error = true config.on_datastore_error = Proc.new do |error, klass, method, arguments| Rails.logger.error("Vanity error: #{error} called by #{klass.inspect}, method #{method.inspect} with arguments #{arguments}") endend

and it does catch the errors, though application still experiences 500 errors because lines of code like:

Vanity.playground.participant_info(vanity_identity)

still throw errors.

We tried to use method Vanity.playground.connected? to check for Vanity state, but it returns true even if datastore errors were reported before the call.

What is a recommended method to use Vanity that it is silent if datastore error has happened? How to check that Vanity is not backed by datastore and cannot be used?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/assaf/vanity/issues/325, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFxKUvkFjhf1IHkRF6W1fgI2d0yL5Lmks5sCL7dgaJpZM4N03ow .

kirhgoff commented 7 years ago

Looks like it is our code carelessly treats results returned from Vanity, which could be nil in case of datastore error. Closing issue