Skip to content

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Mar 2, 2024

No description provided.

Spring Cloud LoadBalancer creates a separate Spring child context for each service id. By default, these contexts are initialised lazily, whenever the first request for a service id is being load-balanced.

You can choose to load those contexts eagerly. In order to do that, specify the service ids for which you want to do eager load using the `spring.cloud-loadbalancer.eager-load.clients` property.
You can choose to load those contexts eagerly. In order to do that, specify the service ids for which you want to do eager load using the `spring.cloud-loadbalancer.eager-load.clients` property, for example:
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 was writing some integration tests for spring-cloud-kubernetes (where I work most) and in one of them, I wanted to eager init load balancer. The documentation here was not clear enough for me that this property is actually an array of elements. imho, adding such a small example makes it clear.

@wind57 wind57 marked this pull request as ready for review March 2, 2024 08:14
@wind57
Copy link
Contributor Author

wind57 commented Mar 2, 2024

while this might be a little beneficial, the only reason I wanted to do eager initialization, is because I don't know how to retrieve the ServiceInstanceListSupplier that is created lazily. In other words: how do I retrieve the ServiceInstanceListSupplier at runtime, after the first call to load balancer. I tried things like getBeansOfType(ServiceInstanceListSupplier.class) or using ObjectProvider, but none worked.

In case you think this should be a separate question, just let me know...


Spring Cloud LoadBalancer creates a separate Spring child context for each service id. By default, these contexts are initialised lazily, whenever the first request for a service id is being load-balanced.

You can choose to load those contexts eagerly. In order to do that, specify the service ids for which you want to do eager load using the `spring.cloud-loadbalancer.eager-load.clients` property.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed a typo here, too:

spring.cloud-loadbalancer.eager-load.clients

vs

spring.cloud.loadbalancer.eager-load.clients

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

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants