couchbaselabs / quarkus-couchbase

Quarkus Couchbase Extension
Apache License 2.0
7 stars 3 forks source link

Make quarkus.couchbase.connection-string optional #5

Open zbendhiba opened 2 years ago

zbendhiba commented 2 years ago

Hello team, I've been running first tests for our camel-quarkus couchbase extension.

There are 2 problems with the fact that the configuration : quarkus.couchbase.connection-string is mandatory.

  1. The fact that it is mandatory. Look at this example here. It is a very simple Quarkus app that has a basic Rest endpoint. The fact that the couchbase extension exists in the pom.xml file, themvn install fails. There is no usage of Couchbase here, so this doesn't have to fail. Note that this is a blocker for us at camel-quarkus, as we manage the configuration under the hood.
  2. Because of 1., we can't configure this configuration in the QuarkusTestResource classes in our integration tests

The error is

java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.runtime.configuration.ConfigurationException: SRCFG00014: The config property quarkus.couchbase.connection-string is required but it could not be found in any config source
Caused by: java.lang.RuntimeException: io.quarkus.runtime.configuration.ConfigurationException: SRCFG00014: The config property quarkus.couchbase.connection-string is required but it could not be found in any config source
Caused by: io.quarkus.runtime.configuration.ConfigurationException: SRCFG00014: The config property quarkus.couchbase.connection-string is required but it could not be found in any config source
Caused by: java.util.NoSuchElementException: SRCFG00014: The config property quarkus.couchbase.connection-string is required but it could not be found in any config source
programmatix commented 2 years ago

Hi @zbendhiba, thank you for raising this with us, and apologies it's taken a couple of weeks to get back to you. The extension is in alpha status so it's very possible to make changes. But, on this one, I'm somewhat confused as to the use-case. I guess my question is, why would you (or any user) need the Couchbase extension in the pom unless you're planning on using Couchbase? There's also the question of, if the user has not specified a connection string, what do we connect to by default? Localhost could be an option, but the same question applies to the other two mandatory properties, username and password, and defaults are both less clear and less useful there. Also we'd be swapping a clear "you haven't provided a connection string" error for a rather more unclear one related to failing to connect to a cluster. I'm concerned it would reduce UX.

Perhaps it is a possibility to not have the mandatory parameters but instead raise a runtime error if they have not been specified - but only if the Couchbase Cluster object is actually used. Presumably that would work for your use-case?

A useful next step may be for me to check out what other database Quarkus extensions do to handle this.