Skip to content

Commit

Permalink
Reorganize Hibernate Search management config for a Standalone mapper
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Aug 8, 2024
1 parent bb15bea commit 39a1d15
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 @@ -10,7 +10,7 @@
*/
public class HibernateSearchStandaloneEnabled implements BooleanSupplier {

private final HibernateSearchStandaloneBuildTimeConfig config;
protected final HibernateSearchStandaloneBuildTimeConfig config;

HibernateSearchStandaloneEnabled(HibernateSearchStandaloneBuildTimeConfig 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.standalone.elasticsearch.deployment;

import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management.HibernateSearchStandaloneManagementConfig;

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

private final HibernateSearchStandaloneManagementConfig config;

HibernateSearchStandaloneManagementEnabled(HibernateSearchStandaloneBuildTimeConfig config,
HibernateSearchStandaloneManagementConfig managementConfig) {
HibernateSearchStandaloneManagementEnabled(HibernateSearchStandaloneBuildTimeConfig 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 @@ -63,7 +63,6 @@
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneBuildTimeConfig.ElasticsearchIndexBuildTimeConfig;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRecorder;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.HibernateSearchStandaloneRuntimeConfig;
import io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management.HibernateSearchStandaloneManagementConfig;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.runtime.configuration.ConfigurationException;
import io.quarkus.vertx.http.deployment.spi.RouteBuildItem;
Expand Down Expand Up @@ -370,10 +369,12 @@ void devServices(Optional<HibernateSearchStandaloneEnabledBuildItem> enabled,
@BuildStep(onlyIf = HibernateSearchStandaloneManagementEnabled.class)
void createManagementRoutes(BuildProducer<RouteBuildItem> routes,
HibernateSearchStandaloneRecorder recorder,
HibernateSearchStandaloneManagementConfig managementConfig) {
HibernateSearchStandaloneBuildTimeConfig hibernateSearchStandaloneBuildTimeConfig) {

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

routes.produce(RouteBuildItem.newManagementRoute(
managementConfig.rootPath() + (managementConfig.rootPath().endsWith("/") ? "" : "/") + "reindex")
managementRootPath + (managementRootPath.endsWith("/") ? "" : "/") + "reindex")
.withRoutePathConfigKey("quarkus.hibernate-search-standalone.management.root-path")
.withRequestHandler(recorder.managementHandler())
.displayOnNotFoundPage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public interface HibernateSearchStandaloneBuildTimeConfig {
*/
Optional<String> backgroundFailureHandler();

/**
* Management interface.
*/
@ConfigDocSection
HibernateSearchStandaloneBuildTimeConfigManagement management();

/**
* Configuration related to the mapping.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package io.quarkus.hibernate.search.standalone.elasticsearch.runtime.management;
package io.quarkus.hibernate.search.standalone.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-standalone.management")
@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
public interface HibernateSearchStandaloneManagementConfig {
@ConfigGroup
public interface HibernateSearchStandaloneBuildTimeConfigManagement {

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

0 comments on commit 39a1d15

Please sign in to comment.