Skip to content
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

Introduce a starter for HTTP Client applications #42715

Open
ThomasVitale opened this issue Oct 16, 2024 · 3 comments
Open

Introduce a starter for HTTP Client applications #42715

ThomasVitale opened this issue Oct 16, 2024 · 3 comments
Labels
status: blocked An issue that's blocked on an external project change theme: structure Issues related to the structure of the project and its code type: enhancement A general enhancement

Comments

@ThomasVitale
Copy link

ThomasVitale commented Oct 16, 2024

I'd like to suggest introducing a new Spring Boot starter aimed at client applications, with the necessary dependencies and autoconfiguration (e.g. RestClientAutoConfiguration) for HTTP and for related slice tests. Perhaps, two starters for imperative and reactive scenarios: spring-boot-http-client-starter and spring-boot-http-client-reactive-starter, or something like that.

In the past few years, building CLI applications with Java has become more and more common, also thanks to projects like GraalVM and Spring Shell. Reducing the friction for bootstrapping a CLI project that needs HTTP interactions would greatly help increase the adoption of the Spring stack for this purpose.

Most recently, Spring AI brought new use cases for CLI applications, which would need an HTTP client infrastructure without the burden of an entire web server stack.

Besides the CLI use case, introducing such a starter would help imperative applications that need a WebClient (required by Spring AI for streaming scenarios, because RestClient doesn't support streaming) include just client dependencies instead of the entire server stack.

Whether it is possible to set the spring.main.web-application-type=none property for disabling the web server part of the autoconfigured stack, the developer experience could be improved. Also, including several additional server dependencies which are not used is not ideal, especially from a maintenance and supply chain management point of view.

It would be great to be able to bootstrap a client-only application from Spring Initializr. I'm available to help with the implementation, if you think this is something that makes sense for the project.

Related issues on Spring Boot:

Related issues on Spring AI:

Related issues on Spring Pet Clinic:

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 16, 2024
@wilkinsona
Copy link
Member

Thanks for the suggestion. As things stand, we can't differentiate between a dependency on spring-webflux that's intended to provide a reactive HTTP client and a dependency on spring-webflux that's intended to provide a reactive web server. As such, this is largely a duplicate of #12973 and/or #37599. We can leave this issue open to consider providing a starter or two for HTTP client applications, but it's blocked until one or both of those issues has been tackled.

@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 16, 2024
@wilkinsona wilkinsona added this to the General Backlog milestone Oct 16, 2024
@wilkinsona wilkinsona added the status: blocked An issue that's blocked on an external project change label Oct 16, 2024
@ThomasVitale
Copy link
Author

Ok, thanks for the quick and detailed answer.

@codefromthecrypt
Copy link
Contributor

fyi I ran into this, and while tricky hope there's a way to do this. I want to be able to make CLI commands with spring AI and not have to add tracing code to get a root span for all its work done.

This isn't isolated to spring boot, the problem with client and server in the same stack.

For example, in python, there's also a tension about flask, as "click" (CLI commands) could co-exist with server routes. The issue plays out in observability. You totally want a root span for a one-shot CLI function (otherwise you'll have a disaster of individual traces or manual code to make one which is boilerplate even if using annotations). OTOH, if the cli command starts a server, you don't want all http requests spans be rooted with the command to start the server.

There was a glitch of this kind due to conflation and luckily fixed open-telemetry/opentelemetry-python-contrib#3174

Hope these anecdotes help

@philwebb philwebb added the theme: structure Issues related to the structure of the project and its code label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked An issue that's blocked on an external project change theme: structure Issues related to the structure of the project and its code type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants