question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

REST Client Config - Limitations of ConfigRoot `RestClientsConfig`

See original GitHub issue

Describe the bug

We are seeing several issues with the REST Client Config move to the RestClientsConfig ConfigRoot added in https://github.com/quarkusio/quarkus/pull/17220.

Related issues:

One of the main issues seems to be the expectation that the REST Client Config (or at least the URL) can be dynamically changed during runtime by just changing the configuration.

Another issue is the way that RestClientConfig is mapped. The use of public Map<String, RestClientConfig> configs; implies that named configuration (in this case the resource) is added by iterating the Config#getPropertyNames. This is usually ok because for most cases we are not aware of the named configuration and this is the only way to retrieve them. In the particular case of REST Clients, the named configuration is known at build time, but we ignore it and fill in the Map with getPropertyNames ignoring that some Config Sources like Vault do not provide their property names.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:23 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
radcortezcommented, Nov 11, 2021

I think we can try to compromise here a bit. It should be possible to override the default QuarkusRestClientBuilder to dynamically read the configuration, so it is not required to change all the code to use the REST Client builder directly.

Can you please give me an example of what the code would look like?

It depends on how you want to code it but, dynamic config retrieval could be done here by entending this class and overriding the build method.

https://github.com/quarkusio/quarkus/blob/1e517c8cc58a743e879f437821d1cfd9c0c79e0a/extensions/resteasy-classic/rest-client/runtime/src/main/java/io/quarkus/restclient/runtime/QuarkusRestClientBuilder.java#L234

Registration is just a static call to org.eclipse.microprofile.rest.client.spi.RestClientBuilderResolver#setInstance to add a new Resolver for the new Builder. In this way, you are not required to have producer methods to change any of the code where REST Clients are used.

Alternatively, you can modify at your own risk the values of RestClientsConfig 😃

1reaction
frandencommented, Nov 11, 2021

Which is why I metioned above that we should provide some way for the values in application.properties to be made available to the Builder API without requiring users to write this boilterplate.

Ahhh. Got it. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

Quarkus 2.5.1.Final 发布-Linuxeden开源社区
getQuery; #21692 – Copy default methods of a RestClient Reactive interface to ... #21348 – REST Client Config – Limitations of ConfigRoot RestClientsConfig...
Read more >
#quarkus getting started | Explore Tumblr Posts and Blogs | Tumpik
Explore Tumblr blogs with no restrictions, modern design and the best ... #21348 – REST Client Config – Limitations of ConfigRoot RestClientsConfig.
Read more >
chore(deps): update dependency io.quarkus:quarkus ... - GitLab
... #​21348 - REST Client Config - Limitations of ConfigRoot RestClientsConfig; #​21345 - REST Client Configuration via Uppercase/Underscore Environment ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found