
io.quarkus.elasticsearch.restclient.common.deployment.ElasticsearchDevServicesBuildTimeConfig Maven / Gradle / Ivy
package io.quarkus.elasticsearch.restclient.common.deployment;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
@ConfigRoot(name = "elasticsearch.devservices", phase = ConfigPhase.BUILD_TIME)
public class ElasticsearchDevServicesBuildTimeConfig {
/**
* If Dev Services for Elasticsearch has been explicitly enabled or disabled. Dev Services are generally enabled
* by default, unless there is an existing configuration present. For Elasticsearch, Dev Services starts a server unless
* {@code quarkus.elasticsearch.hosts} is set.
*/
@ConfigItem
public Optional enabled = Optional.empty();
/**
* Optional fixed port the dev service will listen to.
*
* If not defined, the port will be chosen randomly.
*/
@ConfigItem
public Optional port;
/**
* Defaults to a distribution inferred from the explicitly configured `image-name` (if any),
* or by default to the distribution configured in depending extensions (e.g. Hibernate Search),
* or by default to `elastic`.
*
* @asciidoclet
*/
@ConfigItem
public Optional distribution;
/**
* The Elasticsearch container image to use.
* Defaults depend on the configured `distribution`:
*
* * For the `elastic` distribution: {elasticsearch-image}
* * For the `opensearch` distribution: {opensearch-image}
*
* @asciidoclet
*/
@ConfigItem
public Optional imageName;
/**
* The value for the ES_JAVA_OPTS env variable.
* Defaults to setting the heap to 512MB min - 1GB max.
*/
@ConfigItem(defaultValue = "-Xms512m -Xmx1g")
public String javaOpts;
/**
* Indicates if the Elasticsearch server managed by Quarkus Dev Services is shared.
* When shared, Quarkus looks for running containers using label-based service discovery.
* If a matching container is found, it is used, and so a second one is not started.
* Otherwise, Dev Services for Elasticsearch starts a new container.
*
* The discovery uses the {@code quarkus-dev-service-elasticsearch} label.
* The value is configured using the {@code service-name} property.
*
* Container sharing is only used in dev mode.
*/
@ConfigItem(defaultValue = "true")
public boolean shared;
/**
* The value of the {@code quarkus-dev-service-elasticsearch} label attached to the started container.
* This property is used when {@code shared} is set to {@code true}.
* In this case, before starting a container, Dev Services for Elasticsearch looks for a container with the
* {@code quarkus-dev-service-elasticsearch} label
* set to the configured value. If found, it will use this container instead of starting a new one. Otherwise it
* starts a new container with the {@code quarkus-dev-service-elasticsearch} label set to the specified value.
*
* This property is used when you need multiple shared Elasticsearch servers.
*/
@ConfigItem(defaultValue = "elasticsearch")
public String serviceName;
/**
* Environment variables that are passed to the container.
*/
@ConfigItem
public Map containerEnv;
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ElasticsearchDevServicesBuildTimeConfig that = (ElasticsearchDevServicesBuildTimeConfig) o;
return Objects.equals(shared, that.shared)
&& Objects.equals(enabled, that.enabled)
&& Objects.equals(port, that.port)
&& Objects.equals(distribution, that.distribution)
&& Objects.equals(imageName, that.imageName)
&& Objects.equals(javaOpts, that.javaOpts)
&& Objects.equals(serviceName, that.serviceName)
&& Objects.equals(containerEnv, that.containerEnv);
}
@Override
public int hashCode() {
return Objects.hash(enabled, port, distribution, imageName, javaOpts, shared, serviceName, containerEnv);
}
public enum Distribution {
ELASTIC,
OPENSEARCH
}
}