Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize Hibernate Search management config #42378

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reorganize Hibernate Search management config
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.
gsmet committed Aug 7, 2024
commit bb15beacc7c797e1efede3e874190994d8a6bda7
Original file line number Diff line number Diff line change
@@ -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;
@@ -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()
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
*/
public class HibernateSearchEnabled implements BooleanSupplier {

private final HibernateSearchElasticsearchBuildTimeConfig config;
protected final HibernateSearchElasticsearchBuildTimeConfig config;

HibernateSearchEnabled(HibernateSearchElasticsearchBuildTimeConfig config) {
this.config = config;
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
@@ -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;
@@ -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.