-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use Stork registrars in standalone way #42161
Use Stork registrars in standalone way #42161
Conversation
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
5fa7ebd
to
084b4f0
Compare
cc @cescoffier |
Can you mark the PR as draft to make sure we do not merge it too eagerly. |
🎊 PR Preview 8e6e43d has been successfully built and deployed to https://quarkus-pr-main-42161-preview.surge.sh/version/main/guides/
|
@cescoffier @aureamunoz i think this is what I need. Will this allow me to programatically add a Consult client. Right now I have a customer converting from Spring Boot and they don't like that they have to do this... /**
* Register our two services in Consul.
*
* Note: this method is called on a worker thread, and so it is allowed to block.
* @throws UnknownHostException
*/
public void init(@Observes StartupEvent ev, Vertx vertx) throws UnknownHostException {
String consulHost = ConfigProvider.getConfig().getValue("quarkus.stork.my-service.service-discovery.consul-host", String.class);
int consulPort = ConfigProvider.getConfig().getValue("quarkus.stork.my-service.service-discovery.consul-port", Integer.class);
ConsulClient client = ConsulClient.create(vertx, new ConsulClientOptions().setHost(consulHost).setPort(consulPort));
int port = ConfigProvider.getConfig().getValue("quarkus.stork.my-service.service-discovery.consul-port", Integer.class);
String address = InetAddress.getLocalHost().getHostAddress();
String name = ConfigProvider.getConfig().getValue("quarkus.application.name", String.class);
client.registerService(
new ServiceOptions().setPort(port).setAddress(address).setName(name).setId("greeting-service"));
} They don't want to write Java code in every service they just want to use configs to register their services? |
Yes, this is what you need @melloware . With this feature you don't event need to instantiate the ConsulClient, stork will do it for you. You just will need to configure in properties the host and port of the Consul. Let me try to provide a quickstart. |
Darn not until 3.16? Also as part of this PR don't the docs need to be updated? |
This PR uses Stork 2.7.0 which contains the documentation. I will also add a quickstart with it in the quickstarts repository. As an example, for now you can check the integration tests. |
@aureamunoz thanks but the IT still does this. Stork.getInstance().getService("my-service").getServiceRegistrar().registerServiceInstance("my-service", "localhost",
red); My client is looking for a ZERO code option so they can just do this.
And it automatically registers the service by |
Ah, I didn't get that. No, that is not possible at the moment. Still need to pass the host and port of the application to register. We had mention something like this here. I could do it but not sure to be able to work on that inmediately. |
OK they are coming from Spring Boot and Spring Boot does this: https://cloud.spring.io/spring-cloud-consul/reference/html/
I think Quarkus should definitely do something similar. |
…rovided in standalone way
084b4f0
to
be13dac
Compare
Ready for review @cescoffier |
@melloware this is heavily dependent on the environment. These days it's rare an application knows it's public IP and public port (typically, as soon as you run in a container you do not have this info anymore). So I would be very cautious about providing such a feature which may end up registering unreachable services. |
This comment has been minimized.
This comment has been minimized.
Status for workflow
|
Status for workflow
|
This requires a new Stork release. Will made it after holidays, from 19th August.