Skip to content

GH-1334: Support for eagerly initializing zuul Ribbon contexts #1749

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

Merged
merged 5 commits into from
Mar 15, 2017

Conversation

bijukunjummen
Copy link
Contributor

@bijukunjummen bijukunjummen commented Mar 3, 2017

#1334 - Supports a way to eagerly initialize Zuul Ribbon Contexts

  • Based on availability of a new flag - zuul.ribbon.eager-load.enabled a Spring listener (ApplicationReadyEvent) goes through the service id's in the ZuulProperties and initializes the Application contexts registered for them

  • Based on the availability of a flag - ribbon.eager-load.enabled, a listener goes through the serviceid's available via ribbon.eager-load.serviceIds and initializes the application contexts registered.

@bijukunjummen
Copy link
Contributor Author

This PR is more of a POC again - this is to see if the direction is okay.

@codecov-io
Copy link

codecov-io commented Mar 3, 2017

Codecov Report

Merging #1749 into master will increase coverage by 0.17%.
The diff coverage is 94.28%.

@@            Coverage Diff             @@
##           master    #1749      +/-   ##
==========================================
+ Coverage   75.22%   75.39%   +0.17%     
==========================================
  Files         200      203       +3     
  Lines        6208     6243      +35     
  Branches      777      781       +4     
==========================================
+ Hits         4670     4707      +37     
+ Misses       1199     1196       -3     
- Partials      339      340       +1
Impacted Files Coverage Δ
...loud/netflix/ribbon/RibbonEagerLoadProperties.java 100% <100%> (ø)
.../cloud/netflix/ribbon/RibbonAutoConfiguration.java 90.9% <100%> (+0.9%)
...work/cloud/netflix/ribbon/SpringClientFactory.java 100% <100%> (ø)
...ramework/cloud/netflix/zuul/ZuulConfiguration.java 87.09% <100%> (+0.43%)
...ix/ribbon/RibbonApplicationContextInitializer.java 90.9% <90.9%> (ø)
...x/zuul/ZuulRouteApplicationContextInitializer.java 91.66% <91.66%> (ø)
...ork/cloud/netflix/zuul/filters/ZuulProperties.java 86.48% <0%> (+1.8%)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66163be...427770a. Read the comment docs.

Copy link
Member

@spencergibb spencergibb left a comment

Choose a reason for hiding this comment

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

My guess is this could be done for feign as well.

@@ -80,28 +80,29 @@ public RibbonLoadBalancerContext getLoadBalancerContext(String serviceId) {
}

static <C> C instantiateWithConfig(AnnotationConfigApplicationContext context,
Class<C> clazz, IClientConfig config) {
Class<C> clazz, IClientConfig config) {
Copy link
Member

Choose a reason for hiding this comment

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

Please revert unneeded formatting, makes it hard to see meaningful changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, not sure how the re-formatting snuck in - will revert back.

@@ -161,6 +163,14 @@ public SendForwardFilter sendForwardFilter() {
return new SendForwardFilter();
}

@Bean
@ConditionalOnProperty(value = "zuul.context.startup.enabled", matchIfMissing = false)
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably have a different name. zuul.ribbon.eager-load=true or something with more meaning.

*
* @author Biju Kunjummen
*/
public class RibbonApplicationContextInitializer
Copy link
Member

Choose a reason for hiding this comment

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

I think there should be a generic ribbon initializer as well. That just takes a simple list of ribbon client names (for non-zuul).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense. This class does that though - taking in a list of Ribbon Client names and initializing the application contexts - would a different name help?

Copy link
Member

Choose a reason for hiding this comment

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

I'm talking about configuration properties.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have introduced a configuration properties now @spencergibb - RibbonEagerLoadProperties with the following properties:

ribbon.eager-load.enabled, ribbon.eager-load.serviceIds and driving the eager registration of Ribbon Client configurations based on these

@bijukunjummen bijukunjummen force-pushed the GH-1334 branch 4 times, most recently from 77e850c to 43c41e1 Compare March 7, 2017 01:50
}
}

// @Override
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented out @Override?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ouch, yes, will restore it :-)

*
* @author Biju Kunjummen
*/
@ConfigurationProperties(prefix = "ribbon.eager-load")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the namespace be ribbon? Since these properties are specific to Spring Cloud Ribbon, should they be spring.cloud.ribbon? Not sure on the conventions we have used in the past. @spencergibb, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

s-c-netflix doesn't follow that convention because we followed the existing netflix configuration

Copy link
Contributor

Choose a reason for hiding this comment

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

OK wasnt sure, thanks for clarifying.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @spencergibb, @ryanjbaxter, this discussion was useful to me too. Anything else that comes to mind on this. Quick question, this PR affects the documentation also, so is how is that typically handled - should I update that too as part of this PR?

Copy link
Member

Choose a reason for hiding this comment

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

@bijukunjummen it would be great if the docs were part of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done @spencergibb, @ryanjbaxter - I have added in the documentation now.

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.

4 participants