Skip to content

Commit

Permalink
Merge pull request #2 from loicmathieu/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
sboeckelmann authored Dec 28, 2022
2 parents 008009d + e3452af commit 6136b83
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 39 deletions.
93 changes: 93 additions & 0 deletions docs/modules/ROOT/pages/includes/quarkus-opensearch.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@

:summaryTableId: quarkus-opensearch
[.configuration-legend]
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime
[.configuration-reference.searchable, cols="80,.^10,.^10"]
|===

h|[[quarkus-opensearch_configuration]]link:#quarkus-opensearch_configuration[Configuration property]

h|Type
h|Default

a|icon:lock[title=Fixed at build time] [[quarkus-opensearch_quarkus.opensearch.health.enabled]]`link:#quarkus-opensearch_quarkus.opensearch.health.enabled[quarkus.opensearch.health.enabled]`

[.description]
--
Whether a health check is published in case the smallrye-health extension is present.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENSEARCH_HEALTH_ENABLED+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_OPENSEARCH_HEALTH_ENABLED+++`
endif::add-copy-button-to-env-var[]
--|boolean
|`true`


a|icon:lock[title=Fixed at build time] [[quarkus-opensearch_quarkus.opensearch.hosts]]`link:#quarkus-opensearch_quarkus.opensearch.hosts[quarkus.opensearch.hosts]`

[.description]
--
The list of hosts of the OpenSearch servers.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENSEARCH_HOSTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_OPENSEARCH_HOSTS+++`
endif::add-copy-button-to-env-var[]
--|list of host:port
|


a|icon:lock[title=Fixed at build time] [[quarkus-opensearch_quarkus.opensearch.username]]`link:#quarkus-opensearch_quarkus.opensearch.username[quarkus.opensearch.username]`

[.description]
--
The username for basic HTTP authentication.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENSEARCH_USERNAME+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_OPENSEARCH_USERNAME+++`
endif::add-copy-button-to-env-var[]
--|string
|


a|icon:lock[title=Fixed at build time] [[quarkus-opensearch_quarkus.opensearch.password]]`link:#quarkus-opensearch_quarkus.opensearch.password[quarkus.opensearch.password]`

[.description]
--
The password for basic HTTP authentication.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENSEARCH_PASSWORD+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_OPENSEARCH_PASSWORD+++`
endif::add-copy-button-to-env-var[]
--|string
|


a|icon:lock[title=Fixed at build time] [[quarkus-opensearch_quarkus.opensearch.io-thread-counts]]`link:#quarkus-opensearch_quarkus.opensearch.io-thread-counts[quarkus.opensearch.io-thread-counts]`

[.description]
--
The number of IO thread. By default, this is the number of locally detected processors.
Thread counts higher than the number of processors should not be necessary because the I/O threads rely on non-blocking operations, but you may want to use a thread count lower than the number of processors.

ifdef::add-copy-button-to-env-var[]
Environment variable: env_var_with_copy_button:+++QUARKUS_OPENSEARCH_IO_THREAD_COUNTS+++[]
endif::add-copy-button-to-env-var[]
ifndef::add-copy-button-to-env-var[]
Environment variable: `+++QUARKUS_OPENSEARCH_IO_THREAD_COUNTS+++`
endif::add-copy-button-to-env-var[]
--|int
|

|===
2 changes: 0 additions & 2 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@ For instance, with Maven, add the following dependency to your POM file:
[[extension-configuration-reference]]
== Extension Configuration Reference

TIP: Remove this section if you don't have Quarkus configuration properties in your extension.

include::includes/quarkus-opensearch.adoc[leveloffset=+1, opts=optional]
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,6 @@ private DevServicesResultBuildItem.RunningDevService startOpenSearch(
return null;
}

// We only support OPENSEARCH container
if (buildItemConfig.distribution == DevservicesOpenSearchBuildItem.Distribution.ELASTIC) {
throw new BuildException("Dev services for OpenSearch doesn't support Elasticsearch", Collections.emptyList());
}

// Hibernate Search OpenSearch have a version configuration property, we need to check that it is coherent
// with the image we are about to launch
if (buildItemConfig.version != null) {
Expand Down Expand Up @@ -204,11 +199,9 @@ private DevServicesResultBuildItem.RunningDevService startOpenSearch(
if (config.serviceName != null) {
container.withLabel(DEV_SERVICE_LABEL, config.serviceName);
}
if (config.port.isPresent()) {
container.setPortBindings(List.of(config.port.get() + ":" + config.port.get()));
}
config.port.ifPresent(integer -> container.setPortBindings(List.of(integer + ":" + integer)));
timeout.ifPresent(container::withStartupTimeout);
container.addEnv("ES_JAVA_OPTS", config.javaOpts);
container.addEnv("OPENSEARCH_JAVA_OPTS", config.javaOpts);

container.start();
return new DevServicesResultBuildItem.RunningDevService(OpenSearchLowLevelClientProcessor.FEATURE,
Expand Down Expand Up @@ -243,7 +236,6 @@ private String displayProperties(Set<String> hostsConfigProperties) {
private static class DevservicesOpenSearchBuildItemsConfiguration {
private Set<String> hostsConfigProperties;
private String version;
private DevservicesOpenSearchBuildItem.Distribution distribution;

private DevservicesOpenSearchBuildItemsConfiguration(List<DevservicesOpenSearchBuildItem> buildItems)
throws BuildException {
Expand All @@ -259,15 +251,6 @@ private DevservicesOpenSearchBuildItemsConfiguration(List<DevservicesOpenSearchB
Collections.emptyList());
}

if (distribution == null) {
distribution = buildItem.getDistribution();
} else if (!distribution.equals(buildItem.getDistribution())) {
// safety guard but should never occur as only Hibernate Search ORM Elasticsearch configure the distribution
throw new BuildException(
"Multiple extensions request OpenSearch Dev Services on different distribution.",
Collections.emptyList());
}

hostsConfigProperties.add(buildItem.getHostsConfigProperty());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ public final class DevservicesOpenSearchBuildItem extends MultiBuildItem {
private final String hostsConfigProperty;

private final String version;
private final Distribution distribution;

public DevservicesOpenSearchBuildItem(String hostsConfigProperty) {
this.hostsConfigProperty = hostsConfigProperty;
this.version = null;
this.distribution = Distribution.OPENSEARCH;
}

public DevservicesOpenSearchBuildItem(String configItemName, String version, Distribution distribution) {
public DevservicesOpenSearchBuildItem(String configItemName, String version) {
this.hostsConfigProperty = configItemName;
this.version = version;
this.distribution = distribution;
}

public String getHostsConfigProperty() {
Expand All @@ -28,12 +25,4 @@ public String getVersion() {
return version;
}

public Distribution getDistribution() {
return distribution;
}

public enum Distribution {
ELASTIC,
OPENSEARCH
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(name = "quarkiverse.opensearch", phase = ConfigPhase.BUILD_TIME)
@ConfigRoot(name = "opensearch", phase = ConfigPhase.BUILD_TIME)
public class OpenSearchBuildTimeConfig {
/**
* Whether a health check is published in case the smallrye-health extension is present.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;

@ConfigRoot(prefix = "quarkiverse", name = "devservices.opensearch", phase = ConfigPhase.BUILD_TIME)
@ConfigRoot(name = "opensearch.devservices", phase = ConfigPhase.BUILD_TIME)
public class OpenSearchDevServicesBuildTimeConfig {

/**
Expand All @@ -33,7 +33,7 @@ public class OpenSearchDevServicesBuildTimeConfig {
public String imageName;

/**
* The value for the ES_JAVA_OPTS env variable.
* The value for the OPENSEARCH_JAVA_OPTS env variable.
* Defaults to setting the heap to 512MB min - 1GB max.
*/
@ConfigItem(defaultValue = "-Xms512m -Xmx1g")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ HealthBuildItem addHealthCheck(OpenSearchBuildTimeConfig buildTimeConfig) {

@BuildStep
DevservicesOpenSearchBuildItem devServices() {
return new DevservicesOpenSearchBuildItem("quarkiverse.opensearch.hosts");
return new DevservicesOpenSearchBuildItem("quarkus.opensearch.hosts");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class OpenSearchClientConfigTest {
static final QuarkusUnitTest TEST = new QuarkusUnitTest()
.setArchiveProducer(
() -> ShrinkWrap.create(JavaArchive.class).addClasses(TestConfigurator.class, RestClientBuilderHelper.class)
.addAsResource(new StringAsset("quarkiverse.opensearch.hosts=opensearch:9200"),
.addAsResource(new StringAsset("quarkus.opensearch.hosts=opensearch:9200"),
"application.properties"));

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;

@ConfigMapping(prefix = "quarkiverse.opensearch")
@ConfigMapping(prefix = "quarkus.opensearch")
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
public interface OpenSearchConfig {

Expand Down

0 comments on commit 6136b83

Please sign in to comment.