Skip to content

@LoadBalanced RestClient#1294

Merged
OlgaMaciaszek merged 8 commits intomainfrom
loadbalanced-restclient
Nov 13, 2023
Merged

@LoadBalanced RestClient#1294
OlgaMaciaszek merged 8 commits intomainfrom
loadbalanced-restclient

Conversation

@OlgaMaciaszek
Copy link
Copy Markdown
Collaborator

Fixes gh-1293.

@OlgaMaciaszek
Copy link
Copy Markdown
Collaborator Author

Hi @Buzzardo, could you please review documentation changes?

Copy link
Copy Markdown
Contributor

@Buzzardo Buzzardo left a comment

Choose a reason for hiding this comment

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

Good changes. Sorry about the code font not rendering in headings. Your instinct to put it in is correct, but it doesn't work well across our various outputs.


[[rest-template-loadbalancer-client]]
== Spring RestTemplate as a Load Balancer Client
== Spring `RestTemplate` as a LoadBalancer Client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the ticks around RestTemplate. Your instinct is right, but we have had trouble with rendering code fonts in headings, so we had to remove it.

Add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project in order to use it.

[[multiple-resttemplate-objects]]
=== Multiple `RestTemplate` Objects
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the ticks around RestTemplate. As I mentioned in the previous comment, we have trouble with rendering the code font in headings.

TIP: If you see errors such as `java.lang.IllegalArgumentException: Can not set org.springframework.web.client.RestTemplate field com.my.app.Foo.restTemplate to com.sun.proxy.$Proxy89`, try injecting `RestOperations` or setting `spring.aop.proxyTargetClass=true`.

[[rest-client-loadbalancer-client]]
== Spring `RestClient` as a LoadBalancer Client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the ticks around RestClient. It won't render correctly.

The `BlockingLoadBalancerClient` is used to create a full physical address.

IMPORTANT: To use a load-balanced `RestClient`, you need to have a Spring LoadBalancer implementation in your classpath.
Add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project in order to use it.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change to:

To use it, add xref:spring-cloud-commons/loadbalancer.adoc#spring-cloud-loadbalancer-starter[Spring Cloud LoadBalancer starter] to your project.


[[webclinet-loadbalancer-client]]
== Spring WebClient as a Load Balancer Client
== Spring `WebClient` as a LoadBalancer Client
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the ticks around WebClient. The code font does not render correctly in headings.

Then, `ReactiveLoadBalancer` is used underneath.

[[multiple-webclient-objects]]
=== Multiple `WebClient.Builder` Objects
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove the ticks around WebClient.Builder. The code font does not render correctly in headings.

== Spring Cloud LoadBalancer integrations

In order to make it easy to use Spring Cloud LoadBalancer, we provide `ReactorLoadBalancerExchangeFilterFunction` that can be used with `WebClient` and `BlockingLoadBalancerClient` that works with `RestTemplate`.
In order to make it easy to use Spring Cloud LoadBalancer, we provide `ReactorLoadBalancerExchangeFilterFunction` that can be used with `WebClient` and `BlockingLoadBalancerClient` that works with `RestTemplate` and `RestClient`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Change to:

To make it easy to use Spring Cloud LoadBalancer, we provide ReactorLoadBalancerExchangeFilterFunction (which can be used with WebClient) and BlockingLoadBalancerClient (which works with RestTemplate and RestClient).


The parentheses break up a long sentence and make it more clear. "In order to" can nearly always be changed to "To". Edit to add: That's not your fault. That sentence had problems in the first place. While we have the chance, though, we may as well improve it.


TIP: For the non-reactive stack, create this supplier with the `withBlockingHealthChecks()`.
You can also pass your own `WebClient` or `RestTemplate` instance to be used for the checks.
You can also pass your own `WebClient`, `RestTemplate` or `RestClient` instance to be used for the checks.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a comma after `RestTemplate. The Spring Style Guide calls for serial commas (a comma before the last item in a list).

@OlgaMaciaszek
Copy link
Copy Markdown
Collaborator Author

Thanks, @Buzzardo 🙂

@OlgaMaciaszek OlgaMaciaszek merged commit dd47ca6 into main Nov 13, 2023
OlgaMaciaszek added a commit that referenced this pull request Nov 13, 2023
@OlgaMaciaszek
Copy link
Copy Markdown
Collaborator Author

Issues in docs fixed within a1c355e.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add load balancer auto-configuration for RestClient

3 participants