Skip to content

Commit

Permalink
Reorganize Hibernate Search management config
Browse files Browse the repository at this point in the history
While it's working fine with the new annotation processor, the config is
not ordered the same and it's better displayed as a section.
Also it looks a bit odd to have a specific root just for that.
  • Loading branch information
gsmet committed Aug 7, 2024
1 parent a34e10f commit bb15bea
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit.ElasticsearchIndexBuildTimeConfig;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchRecorder;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchRuntimeConfig;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.management.HibernateSearchManagementConfig;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.vertx.http.deployment.spi.RouteBuildItem;
Expand Down Expand Up @@ -441,10 +440,12 @@ void devServicesDropAndCreateAndDropByDefault(
@BuildStep(onlyIf = HibernateSearchManagementEnabled.class)
void createManagementRoutes(BuildProducer<RouteBuildItem> routes,
HibernateSearchElasticsearchRecorder recorder,
HibernateSearchManagementConfig managementConfig) {
HibernateSearchElasticsearchBuildTimeConfig hibernateSearchElasticsearchBuildTimeConfig) {

String managementRootPath = hibernateSearchElasticsearchBuildTimeConfig.management().rootPath();

routes.produce(RouteBuildItem.newManagementRoute(
managementConfig.rootPath() + (managementConfig.rootPath().endsWith("/") ? "" : "/") + "reindex")
managementRootPath + (managementRootPath.endsWith("/") ? "" : "/") + "reindex")
.withRoutePathConfigKey("quarkus.hibernate-search-orm.management.root-path")
.withRequestHandler(recorder.managementHandler())
.displayOnNotFoundPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/
public class HibernateSearchEnabled implements BooleanSupplier {

private final HibernateSearchElasticsearchBuildTimeConfig config;
protected final HibernateSearchElasticsearchBuildTimeConfig config;

HibernateSearchEnabled(HibernateSearchElasticsearchBuildTimeConfig config) {
this.config = config;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package io.quarkus.hibernate.search.orm.elasticsearch.deployment;

import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchBuildTimeConfig;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.management.HibernateSearchManagementConfig;

/**
* Supplier that can be used to only run build steps
* if the Hibernate Search extension and its management is enabled.
*/
public class HibernateSearchManagementEnabled extends HibernateSearchEnabled {

private final HibernateSearchManagementConfig config;

HibernateSearchManagementEnabled(HibernateSearchElasticsearchBuildTimeConfig config,
HibernateSearchManagementConfig managementConfig) {
HibernateSearchManagementEnabled(HibernateSearchElasticsearchBuildTimeConfig config) {
super(config);
this.config = managementConfig;
}

@Override
public boolean getAsBoolean() {
return super.getAsBoolean() && config.enabled();
return super.getAsBoolean() && config.management().enabled();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
import io.quarkus.runtime.annotations.ConfigDocMapKey;
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
Expand Down Expand Up @@ -35,4 +36,9 @@ public interface HibernateSearchElasticsearchBuildTimeConfig {
@ConfigDocMapKey("persistence-unit-name")
Map<String, HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit> persistenceUnits();

/**
* Management interface.
*/
@ConfigDocSection
HibernateSearchElasticsearchBuildTimeConfigManagement management();
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.quarkus.hibernate.search.orm.elasticsearch.runtime.management;
package io.quarkus.hibernate.search.orm.elasticsearch.runtime;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.smallrye.config.WithDefault;

@ConfigMapping(prefix = "quarkus.hibernate-search-orm.management")
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
public interface HibernateSearchManagementConfig {
@ConfigGroup
public interface HibernateSearchElasticsearchBuildTimeConfigManagement {

/**
* Root path for reindexing endpoints.
Expand Down

0 comments on commit bb15bea

Please sign in to comment.