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

Avoiding :urgent strategy in the console? #495

Closed
aselder opened this issue Apr 19, 2017 · 3 comments
Closed

Avoiding :urgent strategy in the console? #495

aselder opened this issue Apr 19, 2017 · 3 comments

Comments

@aselder
Copy link

aselder commented Apr 19, 2017

In some of our staging environments we don't have ES hooked up, and it's controlled by an environment variable to set all strategies to :bypass in an initializer. However when you fire up a console in that environment, an instance of the :urgent strategy gets added to the stack:

irb(main):003:0> Chewy.root_strategy
=> :bypass
irb(main):004:0> Chewy.request_strategy
=> :bypass
irb(main):005:0> Chewy.strategy
=> #<Chewy::Strategy:0x00000008545698 @stack=[#<Chewy::Strategy::Base:0x00000008545328>, #<Chewy::Strategy::Bypass:0x00000008544f68>, #<Chewy::Strategy::Urgent:0x0000000b80c658>]>

Is there a way to avoid this :urgent strategy getting added?

Also, ideally I'd love to not have to worry about strategies at all when I just need to completely disable Chewy in certain environments. I'd love for there to be a configuration object like enabled that could be set to true just to stop everything Chewy related.

@aselder
Copy link
Author

aselder commented Apr 19, 2017

I know it's a hack, but I put in the following code in our initializer in the ES off block:

  Chewy::Railtie.console do
    Chewy.strategy.pop if Chewy.strategy.current.name == :urgent
  end

@pyromaniac
Copy link
Contributor

Right now use your hack, I'm going to make the console strategy configurable. Also, you can submit a PR by yourself. Here it is set: https://github.com/toptal/chewy/blob/master/lib/chewy/railtie.rb#L49

@aselder
Copy link
Author

aselder commented May 18, 2017

I'll take a look at adding this functionality while I'm digging into it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants