Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ActiveSupport dependency #99

Merged

Conversation

matthewshafer
Copy link
Collaborator

There were a few places around circuitbox where some active support methods were used, but there was not that many left. I switched those to use methods that come part of ruby. Also added a null notifier that is the default if active support notifications are not defined.

@matthewshafer matthewshafer requested a review from bmorton April 30, 2018 08:24
yarmand
yarmand previously approved these changes Apr 30, 2018
Copy link
Member

@yarmand yarmand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, the dependency on active_support was so annoying from day 1 of the gem. :)

@@ -30,7 +30,7 @@ def initialize(service, options = {})
@notifier = options.fetch(:notifier) { Circuitbox.default_notifier }

@exceptions = options.fetch(:exceptions) { [] }
@exceptions = [Timeout::Error] if @exceptions.blank?
@exceptions = [Timeout::Error] if @exceptions.empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is not one already, I would add a test when @exceptions = nil to be sure the behavior is covered the same way by empty?

Copy link
Collaborator Author

@matthewshafer matthewshafer Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone passes { exceptions: nil } empty is going to fail with NoMethodError (undefined method `empty?' for nil:NilClass). blank? would have returned true. I can't come up with a reason to use circuitbox and pass in no exceptions to monitor so I'm fine with leaving this how it is. Worst case we could do Array(@exceptions) but that just feels like allowing the API to be used incorrectly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this would not be a "tell don't ask" situation here as the default on Timeout::Error is not obvious.
If we want to discourage bad API usage, I think we should then be explicit in the error.

raise 'exceptions need to be an array' unless @exceptions.is_a?(Array)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that makes sense. I'm wondering if we can do a little more cleanup (another PR) where we can move Timeout::Error to the options.fetch call otherwise if :exceptions are specified it needs to be given something that's not empty.

@matthewshafer matthewshafer merged commit 2ca7258 into yammer:master May 5, 2018
@matthewshafer matthewshafer deleted the remove-active-support-dependency branch May 5, 2018 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants