feat: jpa, messaging, notification, mongo, graphql 어댑터터 리펙토링

This commit is contained in:
DongHyeonka
2026-08-18 10:59:56 +09:00
parent 2f5d2fc219
commit e98b56eb03
372 changed files with 25131 additions and 20357 deletions
@@ -0,0 +1,24 @@
package dev.caskeleton.adapter.outbound.messaging.autoconfigure;
import dev.caskeleton.adapter.outbound.messaging.MessagingConfig;
import dev.caskeleton.adapter.outbound.messaging.MessagingSettings;
import dev.caskeleton.adapter.outbound.messaging.kafka.KafkaAdapterConfig;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;
/**
* The one place that decides whether this application publishes to a broker.
*
* <p>Before this, whether {@code app.messaging.broker} was blank was the de-facto switch. That is a
* selector doing a switch's job, and it reads badly in both directions: a blank broker with the
* relay enabled took down startup, while a deployment that wanted no messaging at all still
* assembled settings, a Kafka adapter configuration and two publishers. The broker id now selects
* <em>which</em> transport, and this switch decides <em>whether</em> there is one.
*/
@AutoConfiguration
@ConditionalOnProperty(prefix = "app.messaging", name = "enabled", havingValue = "true")
@EnableConfigurationProperties(MessagingSettings.class)
@Import({MessagingConfig.class, KafkaAdapterConfig.class})
public class MessagingBridgeRootAutoConfiguration {}
@@ -0,0 +1,52 @@
package dev.caskeleton.adapter.outbound.messaging.autoconfigure;
import java.util.Set;
import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;
import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
/**
* Keeps Boot's broker auto-configurations out of the candidate set while messaging is off.
*
* <p>The Kafka and AMQP starters contribute theirs through Boot's import metadata, so a client
* library on the classpath is enough to build a connection factory, a template and a listener
* container — none of which any project condition was consulted about. It also means both brokers
* would assemble at once simply because both libraries are present, which is a different bug the
* same filter prevents.
*/
public final class MessagingOffAutoConfigurationImportFilter
implements AutoConfigurationImportFilter, EnvironmentAware {
private static final String ENABLE_PROPERTY = "app.messaging.enabled";
private static final Set<String> BROKER_AUTO_CONFIGURATIONS =
Set.of(
"org.springframework.boot.kafka.autoconfigure.KafkaAutoConfiguration",
"org.springframework.boot.kafka.autoconfigure.metrics.KafkaMetricsAutoConfiguration",
"org.springframework.boot.amqp.autoconfigure.RabbitAutoConfiguration",
"org.springframework.boot.amqp.autoconfigure.RabbitAnnotationDrivenAutoConfiguration",
"org.springframework.boot.amqp.autoconfigure.health.RabbitHealthContributorAutoConfiguration");
private Environment environment;
@Override
public boolean[] match(String[] candidates, AutoConfigurationMetadata metadata) {
boolean enabled =
environment != null
&& "true".equalsIgnoreCase(environment.getProperty(ENABLE_PROPERTY, "false"));
boolean[] matches = new boolean[candidates.length];
for (int index = 0; index < candidates.length; index++) {
matches[index] =
enabled
|| candidates[index] == null
|| !BROKER_AUTO_CONFIGURATIONS.contains(candidates[index]);
}
return matches;
}
@Override
public void setEnvironment(Environment environment) {
this.environment = environment;
}
}
@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.AutoConfigurationImportFilter=\
dev.caskeleton.adapter.outbound.messaging.autoconfigure.MessagingOffAutoConfigurationImportFilter
@@ -0,0 +1 @@
dev.caskeleton.adapter.outbound.messaging.autoconfigure.MessagingBridgeRootAutoConfiguration