Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
patrox committed Apr 4, 2024
1 parent e5852d0 commit 9f7f050
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/mongodb-dev-services.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ When running the production version of the application, the MongoDB connection n
Most of the time you need to share the server between applications.
Dev Services for MongoDB implements a _service discovery_ mechanism for your multiple Quarkus applications running in _dev_ mode to share a single server.

NOTE: Dev Services for MongoDB starts the container with the `quarkus-dev-service-mongo` label which is used to identify the container.
NOTE: Dev Services for MongoDB starts the container with the `quarkus-dev-service-mongodb` label which is used to identify the container.

If you need multiple (shared) servers, you can configure the `quarkus.mongo.devservices.service-name` attribute and indicate the server name.
If you need multiple (shared) servers, you can configure the `quarkus.mongodb.devservices.service-name` attribute and indicate the server name.
It looks for a container with the same value, or starts a new one if none can be found.
The default service name is `mongo`.
The default service name is `mongodb`.

Sharing is enabled by default in dev mode, but disabled in test mode.
You can disable the sharing with `quarkus.mongo.devservices.shared=false`.
You can disable the sharing with `quarkus.mongodb.devservices.shared=false`.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class DevServicesBuildTimeConfig {
/**
* If DevServices has been explicitly enabled or disabled. DevServices is generally enabled
* by default, unless there is an existing configuration present.
*
* <p>
* When DevServices is enabled Quarkus will attempt to automatically configure and start
* a database when running in Dev or Test mode.
*/
Expand Down Expand Up @@ -46,12 +46,12 @@ public class DevServicesBuildTimeConfig {
public Map<String, String> containerEnv;

/**
* Indicates if the Mongo server managed by Quarkus Dev Services is shared.
* Indicates if the MongoDB 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 Mongo starts a new container.
* Otherwise, Dev Services for MongoDB starts a new container.
* <p>
* The discovery uses the {@code quarkus-dev-service-mongo} label.
* The discovery uses the {@code quarkus-dev-service-mongodb} label.
* The value is configured using the {@code service-name} property.
* <p>
* Container sharing is only used in dev mode.
Expand All @@ -60,15 +60,15 @@ public class DevServicesBuildTimeConfig {
public boolean shared;

/**
* The value of the {@code quarkus-dev-service-mongo} label attached to the started container.
* The value of the {@code quarkus-dev-service-mongodb} 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 Mongo looks for a container with the
* {@code quarkus-dev-service-mongo} label
* In this case, before starting a container, Dev Services for MongoDB looks for a container with the
* {@code quarkus-dev-service-mongodb} 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-mongo} label set to the specified value.
* starts a new container with the {@code quarkus-dev-service-mongodb} label set to the specified value.
* <p>
*/
@ConfigItem(defaultValue = "mongo")
@ConfigItem(defaultValue = "mongodb")
public String serviceName;

}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class DevServicesMongoProcessor {
*/
private static final String DEV_SERVICE_LABEL = "quarkus-dev-service-mongo";

private static final ContainerLocator mongoContainerLocator = new ContainerLocator(DEV_SERVICE_LABEL, MONGO_EXPOSED_PORT);
private static final ContainerLocator MONGO_CONTAINER_LOCATOR = new ContainerLocator(DEV_SERVICE_LABEL, MONGO_EXPOSED_PORT);

@BuildStep
public List<DevServicesResultBuildItem> startMongo(List<MongoConnectionNameBuildItem> mongoConnections,
Expand Down Expand Up @@ -194,7 +194,7 @@ private RunningDevService startMongo(DockerStatusBuildItem dockerStatusBuildItem
mongoDBContainer::close, getConfigPrefix(connectionName) + "connection-string", effectiveUrl);
};

return mongoContainerLocator.locateContainer(capturedProperties.serviceName(), capturedProperties.shared(), launchMode)
return MONGO_CONTAINER_LOCATOR.locateContainer(capturedProperties.serviceName(), capturedProperties.shared(), launchMode)
.map(containerAddress -> {
final String effectiveUrl = getEffectiveUrl(configPrefix, containerAddress.getHost(),
containerAddress.getPort(), capturedProperties);
Expand Down

0 comments on commit 9f7f050

Please sign in to comment.