The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Dev Services para Redis

O Quarkus oferece suporte a um recurso chamado Dev Services que permite que você crie várias origens de dados sem nenhuma configuração. O que isso significa na prática é que, se você tiver o docker rodando e não tiver configurado quarkus.redis.hosts, o Quarkus iniciará automaticamente um contêiner Redis ao executar testes ou o modo de desenvolvimento e configurará automaticamente a conexão.

Propriedades disponíveis para personalizar o Redis DevService.

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Tipo

Padrão

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: QUARKUS_REDIS_DEVSERVICES_ENABLED

Show more

boolean

true

The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: redis/redis-stack:latest.

Environment variable: QUARKUS_REDIS_DEVSERVICES_IMAGE_NAME

Show more

string

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_REDIS_DEVSERVICES_PORT

Show more

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 quarkus-dev-service-redis label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_REDIS_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-redis label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Redis looks for a container with the quarkus-dev-service-redis 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 quarkus-dev-service-redis label set to the specified value.

This property is used when you need multiple shared Redis servers.

Environment variable: QUARKUS_REDIS_DEVSERVICES_SERVICE_NAME

Show more

string

redis

Environment variables that are passed to the container.

Environment variable: QUARKUS_REDIS_DEVSERVICES_CONTAINER_ENV

Show more

Map<String,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: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_ENABLED

Show more

boolean

true

The container image name to use, for container based DevServices providers. If you want to use Redis Stack modules (bloom, graph, search…​), use: redis/redis-stack:latest.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_IMAGE_NAME

Show more

string

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_PORT

Show more

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 quarkus-dev-service-redis label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-redis label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Redis looks for a container with the quarkus-dev-service-redis 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 quarkus-dev-service-redis label set to the specified value.

This property is used when you need multiple shared Redis servers.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_SERVICE_NAME

Show more

string

redis

Environment variables that are passed to the container.

Environment variable: QUARKUS_REDIS__ADDITIONAL_REDIS_CLIENTS__DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>

Ao executar a versão de produção da aplicação, a conexão Redis precisa ser configurada normalmente, portanto, se quiser incluir uma configuração de banco de dados de produção no seu application.properties e continuar a usar o Dev Services, recomendamos que use o perfil %prod. para definir as configurações do Redis.

O Dev Services para Redis conta com o Docker para iniciar o servidor. Se o seu ambiente não for compatível com o Docker, você precisará iniciar o servidor manualmente ou conectar-se a um servidor já em execução.

Se quiser usar os módulos Redis Stack (bloom, graph, search…​), defina o image-name para redis/redis-stack:latest

Servidor compartilhado

Na maioria das vezes, você precisa compartilhar o servidor entre as aplicações. O Dev Services para Redis implementa um mecanismo de descoberta de serviços para que os várias aplicações Quarkus em execução no modo de desenvolvimento compartilhem um único servidor.

O Dev Services para Redis inicia o contêiner com o rótulo quarkus-dev-service-redis que é utilizado para identificar o contêiner.

Se precisar de vários servidores (compartilhados), você pode configurar o atributo quarkus.redis.devservices.service-name e indicar o nome do servidor. Ele procura um contêiner com o mesmo valor ou inicia um novo se nenhum for encontrado. O nome do serviço padrão é redis.

O compartilhamento é ativado por padrão no modo de desenvolvimento, mas desativado no modo de teste. Você pode desativar o compartilhamento com quarkus.redis.devservices.shared=false.

Conteúdo Relacionado