Servicios de desarrollo para Redis
Quarkus supports a feature called Dev Services that allows you to create various datasources without any config. What that means practically, is that if you have docker running and have not configured quarkus.redis.hosts
, Quarkus will automatically start a Redis container when running tests or dev mode, and automatically configure the connection.
Propiedades disponibles para personalizar el Redis DevService.
Configuration property fixed at build time - All other configuration properties are overridable at runtime
Type |
Default |
|
---|---|---|
If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running. Environment variable: |
boolean |
|
The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…), use: Environment variable: |
string |
|
Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. Environment variable: |
int |
|
Indicates if the Redis 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 Redis starts a new container.
The discovery uses the Environment variable: |
boolean |
|
The value of the Environment variable: |
string |
|
If DevServices has been explicitly enabled or disabled. DevServices is generally enabled by default, unless there is an existing configuration present. When DevServices is enabled Quarkus will attempt to automatically configure and start a database when running in Dev or Test mode and when Docker is running. Environment variable: |
boolean |
|
The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…), use: Environment variable: |
string |
|
Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. Environment variable: |
int |
|
Indicates if the Redis 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 Redis starts a new container.
The discovery uses the Environment variable: |
boolean |
|
The value of the Environment variable: |
string |
|
Cuando se ejecuta la versión de producción de la aplicación, la conexión de Redis debe configurarse de forma normal, por lo que si desea incluir una configuración de base de datos de producción en su application.properties
y seguir utilizando los servicios de desarrollo, le recomendamos que utilice el perfil %prod.
para definir su configuración de Redis.
Dev Services for Redis 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.
If you want to use Redis Stack modules (bloom, graph, search…), set the image-name to redis/redis-stack:latest
|
Servidor compartido
La mayoría de las veces se necesita compartir el servidor entre aplicaciones. Dev Services for Redis implementa un mecanismo de descubrimiento de servicios para que tus múltiples aplicaciones Quarkus que se ejecutan en modo dev compartan un único servidor.
Dev Services for Redis inicia el contenedor con la etiqueta quarkus-dev-service-redis que se utiliza para identificar el contenedor.
|
Si necesitas varios servidores (compartidos), puedes configurar el atributo quarkus.redis.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 redis
.
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.redis.devservices.shared=false
.