Servicios de desarrollo para Elasticsearch
Si cualquier extensión relacionada con Elasticsearch está presente (por ejemplo, quarkus-elasticsearch-rest-client
o quarkus-hibernate-search-orm-elasticsearch
), Dev Services for Elasticsearch inicia automáticamente un servidor de Elasticsearch en modo dev y cuando se ejecutan pruebas. Por lo tanto, no tienes que iniciar un servidor manualmente. La aplicación se configura automáticamente.
Activación/desactivación de los servicios de desarrollo para Elasticsearch
Los servicios de desarrollo para Elasticsearch se activan automáticamente a menos que:
-
quarkus.devservices.enabled
se fija enfalse
. -
quarkus.elasticsearch.devservices.enabled
se ajusta afalse
-
la propiedad hosts está configurada, dependiendo de la extensión utilizada puede ser:
-
quarkus.elasticsearch.hosts
-
quarkus.hibernate-search-orm.elasticsearch.hosts
Dev Services for Elasticsearch se basa en Docker para iniciar el servidor. Si su entorno no admite Docker, tendrá que iniciar el servidor manualmente o conectarse a un servidor ya en funcionamiento.
Elasticsearch compartido
A veces es necesario compartir el servidor entre aplicaciones. Dev Services for Elasticsearch implementa un mecanismo de descubrimiento de servicios para que sus múltiples aplicaciones Quarkus que se ejecutan en modo dev compartan un único servidor.
Dev Services for Elasticsearch inicia el contenedor con la etiqueta quarkus-dev-service-elasticsearch que se utiliza para identificar el contenedor.
|
Si necesitas varios servidores (compartidos), puedes configurar el atributo quarkus.elasticsearch.devservices.service-name
e indicar el nombre del servidor. Se busca un contenedor con el mismo valor, o se inicia uno nuevo si no se encuentra ninguno. El nombre de servicio por defecto es elasticsearch
.
El uso compartido está activado por defecto en el modo de desarrollo, pero está desactivada en el modo de prueba. Puede desactivar el uso compartido con quarkus.elasticsearch.devservices.shared=false
.
Ajuste del puerto
Por defecto, Dev Services for Elasticsearch elige un puerto aleatorio y configura la aplicación. Puedes establecer el puerto configurando la propiedad quarkus.elasticsearch.devservices.port
.
Tenga en cuenta que la propiedad de hosts de Elasticsearch se configura automáticamente con el puerto elegido.
Configuración de la imagen
Dev Services for Elasticsearch support distributions based on both Elasticsearch and OpenSearch images.
When using Hibernate Search, Dev Services will default to Elasticsearch or OpenSearch based on Hibernate Search configuration.
Otherwise, Dev Services will default to Elasticsearch. To use OpenSearch, configure the distribution explicitly:
quarkus.elasticsearch.devservices.distribution=opensearch
If you need to use a different Elasticsearch or OpenSearch image than the default one you can configure it via:
quarkus.elasticsearch.devservices.image-name=docker.io/elastic/elasticsearch:8.9.1
For exotic image names, Quarkus might be unable to infer the distribution (elastic
or opensearch
). In these cases starting the Dev Services will fail, and you will need to configure the distribution explicitly:
quarkus.elasticsearch.devservices.image-name=my-custom-image-with-no-clue-about-the-distribution:1.0
quarkus.elasticsearch.devservices.distribution=elasticsearch
Limitaciones actuales
Actualmente, sólo se admite el backend predeterminado para Hibernate Search Elasticsearch, porque Dev Services for Elasticsearch sólo puede iniciar un contenedor de Elasticsearch.
Referencia de configuración
Configuration property fixed at build time - All other configuration properties are overridable at runtime
Type |
Default |
|
---|---|---|
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 Environment variable: Show more |
boolean |
|
Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. Environment variable: Show more |
int |
|
Defaults to a distribution inferred from the explicitly configured Environment variable: Show more |
|
|
The Elasticsearch container image to use.
Defaults depend on the configured
Environment variable: Show more |
string |
|
The value for the ES_JAVA_OPTS env variable. Defaults to setting the heap to 512MB min - 1GB max. Environment variable: Show more |
string |
|
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 Container sharing is only used in dev mode. Environment variable: Show more |
boolean |
|
The value of the This property is used when you need multiple shared Elasticsearch servers. Environment variable: Show more |
string |
|
Environment variables that are passed to the container. Environment variable: Show more |
|