Skip to content

Commit

Permalink
Merge pull request #32711 from cescoffier/fix-stork-missing-beans
Browse files Browse the repository at this point in the history
Add service registars and loaders to the list of beans to keep
  • Loading branch information
geoand authored Apr 18, 2023
2 parents 05670a8 + 9bbfe72 commit 0dec6f9
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@
import io.quarkus.vertx.deployment.VertxBuildItem;
import io.smallrye.stork.spi.LoadBalancerProvider;
import io.smallrye.stork.spi.ServiceDiscoveryProvider;
import io.smallrye.stork.spi.ServiceRegistrarProvider;
import io.smallrye.stork.spi.internal.LoadBalancerLoader;
import io.smallrye.stork.spi.internal.ServiceDiscoveryLoader;
import io.smallrye.stork.spi.internal.ServiceRegistrarLoader;

public class SmallRyeStorkProcessor {

private static final String KUBERNETES_SERVICE_DISCOVERY_PROVIDER = "io.smallrye.stork.servicediscovery.kubernetes.KubernetesServiceDiscoveryProvider";
private static final Logger LOGGER = Logger.getLogger(SmallRyeStorkProcessor.class.getName());

@BuildStep
void registerServiceProviders(BuildProducer<ServiceProviderBuildItem> services, Capabilities capabilities) {
void registerServiceProviders(BuildProducer<ServiceProviderBuildItem> services) {
services.produce(new ServiceProviderBuildItem(io.smallrye.stork.spi.config.ConfigProvider.class.getName(),
StorkConfigProvider.class.getName()));
for (Class<?> providerClass : asList(LoadBalancerLoader.class, ServiceDiscoveryLoader.class)) {
for (Class<?> providerClass : asList(LoadBalancerLoader.class, ServiceDiscoveryLoader.class,
ServiceRegistrarLoader.class)) {
services.produce(ServiceProviderBuildItem.allProvidersFromClassPath(providerClass.getName()));
}
}
Expand All @@ -47,11 +50,15 @@ void registerServiceProviders(BuildProducer<ServiceProviderBuildItem> services,
UnremovableBeanBuildItem unremoveableBeans() {
return UnremovableBeanBuildItem.beanTypes(
DotName.createSimple(ServiceDiscoveryProvider.class),
DotName.createSimple(LoadBalancerProvider.class));
DotName.createSimple(ServiceDiscoveryLoader.class),
DotName.createSimple(LoadBalancerProvider.class),
DotName.createSimple(LoadBalancerLoader.class),
DotName.createSimple(ServiceRegistrarProvider.class),
DotName.createSimple(ServiceRegistrarLoader.class));
}

/**
* This build step is the fix for https://github.com/quarkusio/quarkus/issues/24444.
* This build step is the fix for <a href="https://github.com/quarkusio/quarkus/issues/24444">#24444</a>.
* Because Stork itself cannot depend on Quarkus, and we do not want to have extensions for all the service
* discovery and load-balancer providers, we work around the issue by detecting when the kubernetes service
* discovery is used and if the kubernetes extension is used.
Expand Down

0 comments on commit 0dec6f9

Please sign in to comment.