spring-cloud / spring-cloud/spring-cloud-commons

Support @LoadBalanced Annotation On Classes

Open
#492 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement waiting for votes
Dominant language
Java
Stars
751
Forks
744
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Hi all,

I was trying to have my RestTemplate (customized with some methods) also aware of load balancing options. In order to do that, I tried to go with "@LoadBalanced" options.
Everything works, the only problem I got is that the annotation is not applicable to class, so that instead of doing:

@LoadBalanced
@Service
public class CredentialsTemplate extends RestTemplate {

    public List<CredentialsRemoteResource> getCredentials(String username) {
    //my custom method
    }
}

I had to do something like this:

@Configuration
public class RestConfiguration {

    @LoadBalanced
    @Bean
    public CredentialsTemplate credentialsTemplate() {
        return new CredentialsTemplate();
    }
}

only to put the annotation. Is (maybe) possible to extend the annotation so that it can be used together the service annotation?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the @LoadBalanced annotation and the processing that currently handles it on @Bean methods, then compare that path with the @Service and RestTemplate examples in the issue. Done means a custom RestTemplate subclass can use @LoadBalanced at class level alongside @Service and receives the same load-balancing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.