review-followup Wave 3 라운드 2(P18): outbox canonical 통일, composition 모듈, legacy Kafka seam 삭제

- 결정 7: `LegacyOutboxAppendPort`·legacy 저장 모델·relay·Kafka R0 seam 삭제, 템플릿 JSON encoder(`JsonIntegrationEventEncoder`),
  durable operation·sample 이벤트가 `OutboxAppendPort` + encoder로, persistence-jpa V19(pre-canonical 미발행 row 거부)
- 결정 3: outbox relay·멱등성 executor 조립을 `composition:outbox-relay`·`composition:idempotency`로,
  sample이 복사한 bootstrap 인프라를 `composition:service-runtime`으로(sample `SampleIdempotencyConfig` 복사본 삭제)
- persistence-jpa outbox·멱등성 패키지 feature 기준 이동, messaging outbox·inbox leaf를 reliability / reliability-jdbc-postgresql로
- messaging outbox header를 jsonb로(P18-new-1 — `\`로 끝나는 값이 다음 header를 삼키던 결함)
- 통합(충돌 22건): P25 A-10c(전략 선택 설정 삭제)를 service-runtime `DomainContextConfig`에 적용, P25 startup 예외 통합을
  composition 설정 테스트에, P25 `CommandUseCase.handle` 이름을 PG 통합 테스트에, P15 `EventJson`은 호출자 0이 되어 삭제
- root CLAUDE.md의 legacy seam 문장 수정(P18-new-2)

검증: ./gradlew check architectureCheck verifyDependencyLocks verifyPublicPathSnapshot :app-bootstrap:verifyEnvKeys
configContractCheck :app-bootstrap:integrationTest :sample-portfolio:integrationTest :sample-portfolio:systemTest
persistence-jpa jpaPlatformContractTest·postgresql{Idempotency,OutboxAppendTransactional,OutboxConcurrentRelay,OutboxRowLifecycle}IntegrationTest
:messaging:messaging-reliability-jdbc-postgresql:integrationTest --continue 통과(700 task)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-29 12:30:01 +09:00
co-authored by Claude Opus 5.5
parent 25de288ab4
commit 423a29c46f
329 changed files with 6380 additions and 6850 deletions
+93
View File
@@ -0,0 +1,93 @@
# composition:idempotency — 요청 멱등성 executor 조립
- Module ID: `composition-idempotency`
- Gradle path: `:composition:idempotency`
- Package: `dev.caskeleton.composition.idempotency`
- 테스트: `./gradlew :composition:idempotency:test --console=plain`
## 제공하는 것
선택한 provider의 저장소 위에 `IdempotencyExecutor`를 하나 만든다. KEYED use case는
application-core의 `IdempotencyExecutor`만 받는다.
```
composition:idempotency
├─ IdempotencyAutoConfiguration provider != disabled 일 때만: 설정 바인딩 + executor 하나
├─ IdempotencySettings 수명 정책(lease·replay TTL·retention·codec·revision), strict 바인딩
└─ config/module-defaults/idempotency.yml (설정 기본값, support 로더가 읽음)
```
- 저장소는 포트(`IdempotencyStorePort`)다. Redis는 `adapter:outbound:cache-redis`, PostgreSQL은
`adapter:outbound:persistence-jpa`가 `ca-skeleton.capabilities.idempotency.provider`에 따라 하나를
기여한다. 선택한 provider의 저장소가 정확히 하나가 아니면(0개: 모듈이 없거나 꺼짐, 2개: 다른
곳이 하나 더 등록) 기동이 개수와 함께 실패한다.
- 켜기와 끄기: 모듈이 있어도 `provider=disabled`(기본)면 아무것도 바인딩하거나 만들지 않는다.
- 설정 바인딩은 `StrictSettingsBinder`다. 같은 prefix 아래 Redis 저장소가 자기 키(`key-version`,
`command-timeout`)를 두므로 그 두 키만 빼고 엄격하게 본다. 수명 정책 키를 잘못 쓰면 기본값이
조용히 쓰이는 대신 기동이 실패한다.
- app-bootstrap과 sample-portfolio가 같은 한 줄을 쓴다. 예전의 sample 복사본
(`SampleIdempotencyConfig`, 상한 검증 없이 `Binder`로 읽고 저장소를 하나로 가정)은 삭제했다.
## 추가할 한 줄
```groovy
// app-bootstrap/build.gradle (sample-portfolio/build.gradle 도 같다)
runtimeOnly project(':composition:idempotency') // 요청 멱등성 executor
```
기본 조립에 있다. provider가 `disabled`면 꺼져 있으므로 저장소 모듈 없이도 안전하다. 이 줄을 지우면
executor, 설정 기본값이 함께 빠진다(그때 KEYED use case는 executor를 받지 못해 기동이 실패한다).
## 필요한 env 키
전체 목록과 타입은 `docs/registries/env-keys.yaml`의 `APP_IDEMPOTENCY_*` 행이 SSOT다.
| 언제 | 키 |
| --- | --- |
| 켤 때 | `APP_IDEMPOTENCY_PROVIDER` (`redis` 또는 `postgresql`), 그리고 그 provider 모듈의 줄과 env |
| 조정할 때 | `APP_IDEMPOTENCY_PROCESSING_LEASE`(≤1h), `APP_IDEMPOTENCY_TTL`(≤72h), `APP_IDEMPOTENCY_FAILURE_RETENTION`(≤30d) |
## 설계 결정 참조 (app-bootstrap에서 옮김)
이 모듈의 코드는 2026-09-28에 app-bootstrap `autoconfigure/idempotency`에서 옮겨 왔다(소유자 결정 3). 아래 근거는 그때의 기록이다.
### IdempotencyAutoConfiguration
- **`IdempotencyExecutor`를 여기서 한 번만 만든다.** provider 모듈은 `IdempotencyStorePort`만
내놓는다 — `redis`는 `cache-redis`의 `RedisIdempotencyConfig`, `postgresql`은 `persistence-jpa`의
`PostgreSqlIdempotencyStoreConfig`. lease·replay TTL·retention·codec id·policy revision 은 어느
store 든 같은 정책이라 `IdempotencySettings` 하나에서 읽는다. executor 를 application-core 밖에서
만드는 이유는 이 설정을 `application-core`가 직접 읽으면 안 되기 때문이다.
- **store 가 정확히 하나가 아니면 기동을 거부한다.** 0개는 provider 모듈이 runtime classpath 에
없거나 스위치가 꺼진 경우, 2개는 다른 무언가가 store 를 등록한 경우다. 둘 다 빈 누락 오류나 엉뚱한
store 로 요청을 처리하는 대신 개수를 담은 startup 실패로 드러난다.
- `provider=disabled`(기본)면 executor 빈 자체가 없다. `jdbc` 값과 V1 조립(`IdempotencyConfig`,
`config/idempotency.yml`)은 삭제됐다.
- `postgresql` provider 는 PostgreSQL data source 가 아니면 기동을 거부한다. `bootRunH2` 에서는
`disabled` 나 `redis` 를 쓴다.
### IdempotencySettings
- `ca-skeleton.capabilities.idempotency` 에 바인딩되는 유일한 설정 record 다(값은
`config/module-defaults/idempotency.yml`).
| 키 | env | 기본값 | 상한 |
| --- | --- | --- | --- |
| `provider` | `APP_IDEMPOTENCY_PROVIDER` | `disabled` | `disabled` \| `redis` \| `postgresql` |
| `processing-lease` | `APP_IDEMPOTENCY_PROCESSING_LEASE` | 30s | 1h |
| `replay-ttl` | `APP_IDEMPOTENCY_TTL` | 24h | 72h |
| `failure-retention` | `APP_IDEMPOTENCY_FAILURE_RETENTION` | 24h | 30d |
| `response-codec-id` | — | `json-v2` | 1–64자 |
| `policy-revision` | — | 2 | 양수 |
| `reaper-interval` | — | 10m | 양수 |
Redis store 튜닝값 `key-version`, `command-timeout`(`APP_IDEMPOTENCY_REDIS_COMMAND_TIMEOUT`)도
같은 prefix 아래 있지만 lifecycle 정책이 아니라서 이 record 에 두지 않고 `cache-redis`가 읽는다.
- **상한 검사는 컴팩트 생성자에서 fail-fast 로 던진다.** `Duration`의 상한은 JSR-303(`@Valid`)
애너테이션으로 표현할 수 없어 생성자에서 직접 검증한다. 검증을 느슨하게 두면 과도하게 긴 TTL 이
저장소를 조용히 부풀리고 멱등성 키 추측 공격의 유효 시간 창을 넓히기 때문에, 부팅 시점에 즉시
실패시키는 쪽을 택했다.
- **replay TTL 상한(72h) / 기본값(24h)을 바꿀 때는 보안 베이스라인의 JWT 키 회전 겹침(overlap)
윈도와 반드시 함께 검토해야 한다.** 멱등성 레코드의 수명이 키 회전 겹침 윈도(현재 24h)보다 길면,
가명화(pseudonym) 기준이 회전된 principal 에 대해 레코드가 재생(replay)될 수 있다. 이 불변식을
강제하는 CI 게이트는 security-operational-baseline 쪽에 위임돼 있다.
- **`reaper-interval`은 전용 환경변수가 없다.** reaper 실행 주기는 비밀이나 배포별 값이 아니라 순수
운영 튜닝 값이다. reaper 는 provider 가 `postgresql` 일 때만 돈다.
+35
View File
@@ -0,0 +1,35 @@
plugins {
id 'ca.spring-library'
id 'ca.spring-config'
}
// The request-idempotency composition, selected by one line in a composition root:
//
// runtimeOnly project(':composition:idempotency')
//
// It builds the one IdempotencyExecutor over whichever IdempotencyStorePort the selected provider
// contributes (Redis from cache-redis, PostgreSQL from persistence-jpa), and ships the lifecycle
// settings (config/module-defaults/idempotency.yml). It names no provider module: the store is a
// port. app-bootstrap and sample-portfolio take the same line, so the executor is built one way.
//
// Not a composition root: it composes one capability and does not run. Same shape as
// :composition:notification-platform.
dependencies {
implementation project(':application-core')
// StrictSettingsBinder and the typed startup failures.
implementation project(':adapter:outbound:support')
implementation 'org.springframework.boot:spring-boot-autoconfigure'
implementation 'org.springframework:spring-context'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// The executor tests drive the port owner's shared fake store.
testImplementation testFixtures(project(':application-core'))
// IdempotencyAutoConfigurationTest composes the real PostgreSQL provider configuration, so a
// selection that stops reaching it shows up here. Test scope only: nothing in main names it.
testRuntimeOnly project(':adapter:outbound:persistence-jpa')
testImplementation 'org.springframework:spring-jdbc'
testImplementation 'org.mockito:mockito-core'
// IdempotencyModuleDefaultsTest reads the shipped file through the loader that serves it.
testRuntimeOnly 'org.yaml:snakeyaml'
}
+199
View File
@@ -0,0 +1,199 @@
# This is a Gradle generated file for dependency locking.
# Manual edits can break the build and are not advised.
# This file is expected to be part of source control.
biz.aQute.bnd:biz.aQute.bnd.annotation:7.1.0=testCompileClasspath
ch.qos.logback:logback-classic:1.5.38=testCompileClasspath,testRuntimeClasspath
ch.qos.logback:logback-core:1.5.38=testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-annotations:2.21=testCompileClasspath,testRuntimeClasspath
com.fasterxml.jackson.core:jackson-core:2.21.5=testRuntimeClasspath
com.fasterxml.jackson.core:jackson-databind:2.21.5=testRuntimeClasspath
com.fasterxml.jackson:jackson-bom:2.21.5=testRuntimeClasspath
com.fasterxml:classmate:1.7.3=testRuntimeClasspath
com.github.ben-manes.caffeine:caffeine:3.2.4=annotationProcessor,testAnnotationProcessor
com.github.kevinstern:software-and-algorithms:1.0=annotationProcessor,testAnnotationProcessor
com.github.spotbugs:spotbugs-annotations:4.10.2=spotbugs
com.github.spotbugs:spotbugs:4.10.2=spotbugs
com.github.stephenc.jcip:jcip-annotations:1.0-1=spotbugs
com.google.auto.service:auto-service-annotations:1.0.1=annotationProcessor,testAnnotationProcessor
com.google.auto.value:auto-value-annotations:1.9=annotationProcessor,testAnnotationProcessor
com.google.auto:auto-common:1.2.2=annotationProcessor,testAnnotationProcessor
com.google.code.findbugs:jsr305:3.0.2=checkstyle,spotbugs
com.google.code.gson:gson:2.13.2=spotbugs
com.google.errorprone:error_prone_annotation:2.49.0=annotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_annotations:2.38.0=testCompileClasspath
com.google.errorprone:error_prone_annotations:2.41.0=spotbugs
com.google.errorprone:error_prone_annotations:2.47.0=checkstyle
com.google.errorprone:error_prone_annotations:2.49.0=annotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_check_api:2.49.0=annotationProcessor,testAnnotationProcessor
com.google.errorprone:error_prone_core:2.49.0=annotationProcessor,testAnnotationProcessor
com.google.googlejavaformat:google-java-format:1.35.0=annotationProcessor,testAnnotationProcessor
com.google.guava:failureaccess:1.0.3=annotationProcessor,checkstyle,testAnnotationProcessor
com.google.guava:guava:33.5.0-jre=annotationProcessor,testAnnotationProcessor
com.google.guava:guava:33.6.0-jre=checkstyle
com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava=annotationProcessor,checkstyle,testAnnotationProcessor
com.google.j2objc:j2objc-annotations:3.1=annotationProcessor,checkstyle,testAnnotationProcessor
com.google.protobuf:protobuf-java:4.33.2=annotationProcessor,testAnnotationProcessor
com.h2database:h2:2.4.240=testRuntimeClasspath
com.h3xstream.findsecbugs:findsecbugs-plugin:1.14.0=spotbugsPlugins
com.jayway.jsonpath:json-path:2.10.0=testCompileClasspath,testRuntimeClasspath
com.puppycrawl.tools:checkstyle:13.5.0=checkstyle
com.sun.istack:istack-commons-runtime:4.1.2=testRuntimeClasspath
com.vaadin.external.google:android-json:0.0.20131108.vaadin1=testCompileClasspath,testRuntimeClasspath
com.zaxxer:HikariCP:7.0.2=testRuntimeClasspath
commons-beanutils:commons-beanutils:1.11.0=checkstyle
commons-collections:commons-collections:3.2.2=checkstyle
commons-io:commons-io:2.21.0=spotbugs
commons-logging:commons-logging:1.3.6=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
info.picocli:picocli:4.7.7=checkstyle
io.github.eisop:dataflow-errorprone:3.41.0-eisop1=annotationProcessor,testAnnotationProcessor
io.github.java-diff-utils:java-diff-utils:4.12=annotationProcessor,testAnnotationProcessor
io.micrometer:micrometer-commons:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.micrometer:micrometer-core:1.16.7=testRuntimeClasspath
io.micrometer:micrometer-observation:1.16.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
io.projectreactor:reactor-core:3.8.7=testRuntimeClasspath
jakarta.activation:jakarta.activation-api:2.1.4=testCompileClasspath,testRuntimeClasspath
jakarta.annotation:jakarta.annotation-api:3.0.0=testCompileClasspath,testRuntimeClasspath
jakarta.inject:jakarta.inject-api:2.0.1=testRuntimeClasspath
jakarta.persistence:jakarta.persistence-api:3.2.0=testRuntimeClasspath
jakarta.transaction:jakarta.transaction-api:2.0.1=testRuntimeClasspath
jakarta.xml.bind:jakarta.xml.bind-api:4.0.5=testCompileClasspath,testRuntimeClasspath
javax.inject:javax.inject:1=annotationProcessor,testAnnotationProcessor
jaxen:jaxen:2.0.6=spotbugs
net.bytebuddy:byte-buddy-agent:1.17.8=testCompileClasspath,testRuntimeClasspath
net.bytebuddy:byte-buddy:1.17.8=testCompileClasspath,testRuntimeClasspath
net.logstash.logback:logstash-logback-encoder:8.0=testRuntimeClasspath
net.minidev:accessors-smart:2.6.0=testCompileClasspath,testRuntimeClasspath
net.minidev:json-smart:2.6.0=testCompileClasspath,testRuntimeClasspath
net.sf.saxon:Saxon-HE:12.9=checkstyle,spotbugs
org.antlr:antlr4-runtime:4.13.2=checkstyle,testRuntimeClasspath
org.apache.bcel:bcel:6.12.0=spotbugs
org.apache.commons:commons-lang3:3.20.0=checkstyle,spotbugs
org.apache.commons:commons-text:1.15.0=spotbugs
org.apache.commons:commons-text:1.3=checkstyle
org.apache.httpcomponents:httpclient:4.5.13=checkstyle
org.apache.httpcomponents:httpcore:4.4.16=checkstyle
org.apache.logging.log4j:log4j-api:2.25.5=spotbugs,testCompileClasspath,testRuntimeClasspath
org.apache.logging.log4j:log4j-core:2.25.5=spotbugs
org.apache.logging.log4j:log4j-to-slf4j:2.25.5=testCompileClasspath,testRuntimeClasspath
org.apache.maven.doxia:doxia-core:1.12.0=checkstyle
org.apache.maven.doxia:doxia-logging-api:1.12.0=checkstyle
org.apache.maven.doxia:doxia-module-xdoc:1.12.0=checkstyle
org.apache.maven.doxia:doxia-sink-api:1.12.0=checkstyle
org.apache.tomcat.embed:tomcat-embed-core:11.0.24=testCompileClasspath,testRuntimeClasspath
org.apache.tomcat.embed:tomcat-embed-el:11.0.24=testCompileClasspath,testRuntimeClasspath
org.apache.tomcat.embed:tomcat-embed-websocket:11.0.24=testCompileClasspath,testRuntimeClasspath
org.apache.xbean:xbean-reflect:3.7=checkstyle
org.apiguardian:apiguardian-api:1.1.2=testCompileClasspath
org.aspectj:aspectjweaver:1.9.25.1=testRuntimeClasspath
org.assertj:assertj-core:3.27.7=testCompileClasspath,testRuntimeClasspath
org.awaitility:awaitility:4.3.0=testCompileClasspath,testRuntimeClasspath
org.checkerframework:checker-qual:3.55.1=testRuntimeClasspath
org.codehaus.plexus:plexus-classworlds:2.6.0=checkstyle
org.codehaus.plexus:plexus-component-annotations:2.1.0=checkstyle
org.codehaus.plexus:plexus-container-default:2.1.0=checkstyle
org.codehaus.plexus:plexus-utils:3.3.0=checkstyle
org.dom4j:dom4j:2.2.0=spotbugs
org.eclipse.angus:angus-activation:2.0.3=testRuntimeClasspath
org.flywaydb:flyway-core:11.14.1=testRuntimeClasspath
org.flywaydb:flyway-database-postgresql:11.14.1=testRuntimeClasspath
org.glassfish.jaxb:jaxb-core:4.0.9=testRuntimeClasspath
org.glassfish.jaxb:jaxb-runtime:4.0.9=testRuntimeClasspath
org.glassfish.jaxb:txw2:4.0.9=testRuntimeClasspath
org.hamcrest:hamcrest:3.0=testCompileClasspath,testRuntimeClasspath
org.hdrhistogram:HdrHistogram:2.2.2=testRuntimeClasspath
org.hibernate.models:hibernate-models:1.0.1=testRuntimeClasspath
org.hibernate.orm:hibernate-core:7.2.24.Final=testRuntimeClasspath
org.javassist:javassist:3.28.0-GA=checkstyle
org.jboss.logging:jboss-logging:3.6.3.Final=testRuntimeClasspath
org.jspecify:jspecify:1.0.1=annotationProcessor,checkstyle,compileClasspath,runtimeClasspath,testAnnotationProcessor,testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-api:6.0.3=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter-engine:6.0.3=testRuntimeClasspath
org.junit.jupiter:junit-jupiter-params:6.0.3=testCompileClasspath,testRuntimeClasspath
org.junit.jupiter:junit-jupiter:6.0.3=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-commons:6.0.3=testCompileClasspath,testRuntimeClasspath
org.junit.platform:junit-platform-engine:6.0.3=testRuntimeClasspath
org.junit.platform:junit-platform-launcher:6.0.3=testRuntimeClasspath
org.junit:junit-bom:6.0.3=testCompileClasspath,testRuntimeClasspath
org.junit:junit-bom:6.1.0=spotbugs
org.latencyutils:LatencyUtils:2.0.3=testRuntimeClasspath
org.mockito:mockito-core:5.20.0=mockitoAgent,testCompileClasspath,testRuntimeClasspath
org.mockito:mockito-junit-jupiter:5.20.0=testCompileClasspath,testRuntimeClasspath
org.objenesis:objenesis:3.3=testRuntimeClasspath
org.opentest4j:opentest4j:1.3.0=testCompileClasspath,testRuntimeClasspath
org.osgi:org.osgi.annotation.bundle:2.0.0=testCompileClasspath
org.osgi:org.osgi.annotation.versioning:1.1.2=testCompileClasspath
org.osgi:org.osgi.resource:1.0.0=testCompileClasspath
org.osgi:org.osgi.service.serviceloader:1.0.0=testCompileClasspath
org.ow2.asm:asm-analysis:9.10.1=spotbugs
org.ow2.asm:asm-commons:9.10.1=spotbugs
org.ow2.asm:asm-tree:9.10.1=spotbugs
org.ow2.asm:asm-util:9.10.1=spotbugs
org.ow2.asm:asm:9.10.1=spotbugs
org.ow2.asm:asm:9.7.1=testCompileClasspath,testRuntimeClasspath
org.pcollections:pcollections:4.0.1=annotationProcessor,testAnnotationProcessor
org.postgresql:postgresql:42.7.13=testRuntimeClasspath
org.reactivestreams:reactive-streams:1.0.4=testRuntimeClasspath
org.reflections:reflections:0.10.2=checkstyle
org.skyscreamer:jsonassert:1.5.3=testCompileClasspath,testRuntimeClasspath
org.slf4j:jul-to-slf4j:2.0.18=testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-api:2.0.18=runtimeClasspath,spotbugs,spotbugsSlf4j,testCompileClasspath,testRuntimeClasspath
org.slf4j:slf4j-simple:2.0.17=spotbugsSlf4j
org.slf4j:slf4j-simple:2.0.18=checkstyle
org.springframework.boot:spring-boot-autoconfigure:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-configuration-processor:4.0.8=annotationProcessor
org.springframework.boot:spring-boot-data-commons:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-data-jpa:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-flyway:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-hibernate:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-http-converter:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-jackson:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-jdbc:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-jpa:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-persistence:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-resttestclient:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-servlet:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-sql:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-starter-data-jpa:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-starter-flyway:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-starter-jackson-test:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-jackson:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-jdbc:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-starter-logging:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-test:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-tomcat-runtime:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-tomcat:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-webmvc-test:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter-webmvc:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-starter:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-test-autoconfigure:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-test:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-tomcat:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-transaction:4.0.8=testRuntimeClasspath
org.springframework.boot:spring-boot-web-server:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-webmvc-test:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot-webmvc:4.0.8=testCompileClasspath,testRuntimeClasspath
org.springframework.boot:spring-boot:4.0.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework.data:spring-data-commons:4.0.7=testRuntimeClasspath
org.springframework.data:spring-data-jpa:4.0.7=testRuntimeClasspath
org.springframework.integration:spring-integration-core:7.0.6=testRuntimeClasspath
org.springframework.integration:spring-integration-jdbc:7.0.6=testRuntimeClasspath
org.springframework:spring-aop:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework:spring-aspects:7.0.9=testRuntimeClasspath
org.springframework:spring-beans:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework:spring-context:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework:spring-core:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework:spring-expression:7.0.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
org.springframework:spring-jdbc:7.0.9=testCompileClasspath,testRuntimeClasspath
org.springframework:spring-messaging:7.0.9=testRuntimeClasspath
org.springframework:spring-orm:7.0.9=testRuntimeClasspath
org.springframework:spring-test:7.0.9=testCompileClasspath,testRuntimeClasspath
org.springframework:spring-tx:7.0.9=testCompileClasspath,testRuntimeClasspath
org.springframework:spring-web:7.0.9=testCompileClasspath,testRuntimeClasspath
org.springframework:spring-webmvc:7.0.9=testCompileClasspath,testRuntimeClasspath
org.xmlresolver:xmlresolver:5.3.3=checkstyle,spotbugs
org.xmlunit:xmlunit-core:2.10.4=testCompileClasspath,testRuntimeClasspath
org.yaml:snakeyaml:2.5=testCompileClasspath,testRuntimeClasspath
tools.jackson.core:jackson-core:3.1.5=testCompileClasspath,testRuntimeClasspath
tools.jackson.core:jackson-databind:3.1.5=testCompileClasspath,testRuntimeClasspath
tools.jackson:jackson-bom:3.1.5=testCompileClasspath,testRuntimeClasspath
empty=
@@ -0,0 +1,66 @@
package dev.caskeleton.composition.idempotency;
import dev.caskeleton.adapter.outbound.support.startup.StartupFailures;
import dev.caskeleton.application.idempotency.IdempotencyExecutor;
import dev.caskeleton.application.idempotency.IdempotencyStorePort;
import java.util.List;
import java.util.Locale;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
/**
* Assembles the request-idempotency executor, once, for whichever provider is selected.
*
* <p>Providers contribute only an {@link IdempotencyStorePort}: Redis from {@code
* adapter:outbound:cache-redis}, PostgreSQL from {@code adapter:outbound:persistence-jpa}, each
* conditional on {@code ca-skeleton.capabilities.idempotency.provider}. The lifecycle policy —
* lease, replay TTL, retention, codec id, policy revision — is the same whichever store holds the
* records, so it lives in one {@link IdempotencySettings} record and the executor is built here
* from it. Every composition root that serves idempotent requests takes this module rather than a
* copy of it: the application and the sample build the same executor from the same checks.
*
* <p>A selected provider must yield exactly one store. None means the provider's module is not on
* the runtime classpath or its switch is off; two means something else registered one (a scan-found
* stereotype, a hand-written bean). Either is refused at startup with the count, rather than
* surfacing as an unsatisfied dependency or as requests served by the wrong store. The store is
* looked up when the executor is built, not when this class is evaluated, so no ordering against
* the provider modules is needed.
*
* <p>{@code provider=disabled} (the default) is the off switch: nothing is bound or built.
*/
@AutoConfiguration
@ConditionalOnExpression(
"!'${ca-skeleton.capabilities.idempotency.provider:disabled}'.trim()"
+ ".equalsIgnoreCase('disabled')")
public class IdempotencyAutoConfiguration {
@Bean
IdempotencySettings idempotencySettings(Environment environment) {
return IdempotencySettings.bind(environment);
}
@Bean
IdempotencyExecutor idempotencyExecutor(
ObjectProvider<IdempotencyStorePort> stores, IdempotencySettings settings) {
List<IdempotencyStorePort> found = stores.orderedStream().toList();
if (found.size() != 1) {
throw StartupFailures.requiredAdapterDisabled(
"ca-skeleton.capabilities.idempotency.provider="
+ settings.provider().name().toLowerCase(Locale.ROOT)
+ " needs exactly one IdempotencyStorePort, but found "
+ found.size()
+ ". Add the provider's module to the runtime classpath and enable it, and make sure"
+ " nothing else registers a store.");
}
return new IdempotencyExecutor(
found.get(0),
settings.processingLease(),
settings.replayTtl(),
settings.failureRetention(),
settings.responseCodecId(),
settings.policyRevision());
}
}
@@ -0,0 +1,111 @@
package dev.caskeleton.composition.idempotency;
import dev.caskeleton.adapter.outbound.support.StrictSettingsBinder;
import dev.caskeleton.adapter.outbound.support.startup.StartupFailures;
import java.time.Duration;
import java.util.Set;
import org.springframework.core.env.Environment;
/**
* The one settings record for request idempotency, bound at {@code
* ca-skeleton.capabilities.idempotency}. The executor is built from it once, whichever provider
* supplies the store. Every value is checked here, so a bad value fails startup rather than the
* first request.
*
* <p>The Redis store reads its own two knobs ({@code key-version}, {@code command-timeout}) under
* the same prefix; they are store tuning, not lifecycle policy, so they are not repeated here. The
* binding is strict for everything else under the prefix: a misspelt lifecycle key fails startup
* instead of leaving its default silently in force.
*
* @param provider which store is composed: {@code disabled}, {@code redis} or {@code postgresql}
* @param processingLease how long one attempt holds a claim before another may take it over
* @param replayTtl how long a completed response is replayable (at most 72h, D6)
* @param failureRetention how long a failed attempt's evidence is kept
* @param responseCodecId identifier of the codec the stored payload is written with
* @param policyRevision replay policy revision written into and compared on each record
* @param reaperInterval how often the PostgreSQL provider purges expired rows
*/
public record IdempotencySettings(
Provider provider,
Duration processingLease,
Duration replayTtl,
Duration failureRetention,
String responseCodecId,
Integer policyRevision,
Duration reaperInterval) {
static final String PREFIX = "ca-skeleton.capabilities.idempotency";
/** Keys under the prefix that the Redis store binds for itself. */
static final Set<String> STORE_OWNED_KEYS = Set.of("key-version", "command-timeout");
private static final Duration MAX_PROCESSING_LEASE = Duration.ofHours(1);
private static final Duration MAX_REPLAY_TTL = Duration.ofDays(3);
private static final Duration MAX_FAILURE_RETENTION = Duration.ofDays(30);
public IdempotencySettings {
provider = provider == null ? Provider.DISABLED : provider;
processingLease =
bounded(
"processing-lease",
orDefault(processingLease, Duration.ofSeconds(30)),
MAX_PROCESSING_LEASE);
replayTtl = bounded("replay-ttl", orDefault(replayTtl, Duration.ofHours(24)), MAX_REPLAY_TTL);
failureRetention =
bounded(
"failure-retention",
orDefault(failureRetention, Duration.ofHours(24)),
MAX_FAILURE_RETENTION);
reaperInterval =
bounded("reaper-interval", orDefault(reaperInterval, Duration.ofMinutes(10)), null);
responseCodecId = responseCodecId == null ? "json-v2" : responseCodecId;
if (responseCodecId.isBlank() || responseCodecId.length() > 64) {
throw StartupFailures.envValidation(
PREFIX
+ ".response-codec-id must contain 1-64 characters, was '"
+ responseCodecId
+ "'");
}
policyRevision = policyRevision == null ? 2 : policyRevision;
if (policyRevision < 1) {
throw StartupFailures.envValidation(
PREFIX + ".policy-revision must be positive, was " + policyRevision);
}
}
/**
* Binds the prefix strictly, leaving the store's own keys to the store.
*
* @param environment the environment to bind from
* @return the validated settings
*/
public static IdempotencySettings bind(Environment environment) {
return StrictSettingsBinder.bindExcept(
environment, PREFIX, IdempotencySettings.class, STORE_OWNED_KEYS);
}
private static Duration orDefault(Duration value, Duration fallback) {
return value == null ? fallback : value;
}
private static Duration bounded(String key, Duration value, Duration maximum) {
if (value.isZero() || value.isNegative()) {
throw StartupFailures.envValidation(PREFIX + "." + key + " must be positive, was " + value);
}
if (maximum != null && value.compareTo(maximum) > 0) {
throw StartupFailures.envValidation(
PREFIX + "." + key + " must be at most " + maximum + ", was " + value);
}
return value;
}
/** The stores a deployment may select; never inferred from the classpath. */
public enum Provider {
/** No store and no executor: the capability is off. */
DISABLED,
/** The Redis owner-safe store (adapter:outbound:cache-redis). */
REDIS,
/** The PostgreSQL owner-safe store (adapter:outbound:persistence-jpa). */
POSTGRESQL
}
}
@@ -0,0 +1 @@
dev.caskeleton.composition.idempotency.IdempotencyAutoConfiguration
@@ -0,0 +1,20 @@
# 멱등성 제공자 선택과 수명 정책의 설정 기본값. Redis 역할(cache/rate-limit/lease)과 Redis 저장소
# 튜닝(key-version, command-timeout)은 cache-redis 모듈이 config/module-defaults/cache-redis.yml 로
# 가져온다.
#
# adapter:outbound:support 의 ModuleDefaultsEnvironmentPostProcessor 가 읽는다. 우선순위는 가장 낮아서
# application*.yml, 환경 변수, 시스템 속성이 항상 이긴다. 이 모듈을 빌드에서 빼면 이 파일도 함께
# 빠진다.
ca-skeleton:
capabilities:
idempotency:
# disabled | redis | postgresql. Exactly one store; the executor is built once over it from
# the lifecycle keys below, whichever provider is selected. disabled binds and builds nothing.
provider: ${APP_IDEMPOTENCY_PROVIDER:disabled}
# Lifecycle policy (IdempotencySettings), the same whichever provider holds the records.
processing-lease: ${APP_IDEMPOTENCY_PROCESSING_LEASE:30s}
replay-ttl: ${APP_IDEMPOTENCY_TTL:24h}
failure-retention: ${APP_IDEMPOTENCY_FAILURE_RETENTION:24h}
response-codec-id: json-v2
# Numeric: the owner-safe claim writes this into the record and compares it there.
policy-revision: 2
@@ -0,0 +1,126 @@
package dev.caskeleton.composition.idempotency;
import static org.assertj.core.api.Assertions.assertThat;
import dev.caskeleton.application.idempotency.IdempotencyExecutor;
import dev.caskeleton.application.idempotency.IdempotencyStorePort;
import dev.caskeleton.application.idempotency.testkit.InMemoryIdempotencyStore;
import java.time.Clock;
import java.util.Arrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcOperations;
/**
* What each provider selection composes, counted: one executor over exactly one store, or nothing.
*
* <p>The PostgreSQL case uses the real persistence-jpa provider configuration, so a selection that
* stops reaching it shows up here. The Redis store needs a live runtime owner, so a stand-in store
* plays it; what is under test is that the composition root builds the executor once, not the
* store. The component scan of the PostgreSQL store package is included in every case, pinning the
* old regression where a stereotype on the store registered it under every selection.
*/
class IdempotencyAutoConfigurationTest {
private static final String POSTGRESQL_STORE_CONFIG =
"dev.caskeleton.adapter.outbound.persistence.autoconfigure.PostgreSqlIdempotencyStoreConfig";
private final ApplicationContextRunner runner =
new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(IdempotencyAutoConfiguration.class))
.withUserConfiguration(ScannedPersistence.class, postgreSqlStoreConfig())
.withBean(JdbcOperations.class, () -> org.mockito.Mockito.mock(JdbcOperations.class))
.withBean(Clock.class, Clock::systemUTC)
// The schema stream talks to a real database; its own integration test covers it.
.withPropertyValues("ca-skeleton.runtime.migration-on-startup=false");
@Test
void disabledComposesNoExecutorEvenWithAStorePresent() {
runner
.withPropertyValues("ca-skeleton.capabilities.idempotency.provider=disabled")
.withBean(IdempotencyStorePort.class, InMemoryIdempotencyStore::new)
.run(
context ->
assertThat(context).hasNotFailed().doesNotHaveBean(IdempotencyExecutor.class));
}
@Test
void redisComposesOneExecutorOverTheRedisStoreAlone() {
runner
.withPropertyValues("ca-skeleton.capabilities.idempotency.provider=redis")
.withBean(IdempotencyStorePort.class, InMemoryIdempotencyStore::new)
.run(
context ->
assertThat(context)
.hasNotFailed()
.hasSingleBean(IdempotencyExecutor.class)
.getBean(IdempotencyStorePort.class)
.isInstanceOf(InMemoryIdempotencyStore.class));
}
@Test
void postgresqlComposesOneExecutorOverThePersistenceJpaStore() {
runner
.withPropertyValues("ca-skeleton.capabilities.idempotency.provider=postgresql")
.run(
context ->
assertThat(context)
.hasNotFailed()
.hasSingleBean(IdempotencyExecutor.class)
.getBean(IdempotencyStorePort.class)
.extracting(store -> store.getClass().getSimpleName())
.isEqualTo("PostgreSqlOwnerSafeIdempotencyStore"));
}
@Test
@DisplayName("a selected provider whose module contributed no store fails startup with the count")
void selectedProviderWithoutAStoreFailsStartup() {
runner
.withPropertyValues("ca-skeleton.capabilities.idempotency.provider=redis")
.run(
context ->
assertThat(context)
.hasFailed()
.getFailure()
.hasStackTraceContaining(
"provider=redis needs exactly one IdempotencyStorePort")
.hasStackTraceContaining("found 0"));
}
@Test
@DisplayName("a second store beside the selected one fails startup with the count")
void secondStoreBesideTheSelectedOneFailsStartup() {
runner
.withPropertyValues("ca-skeleton.capabilities.idempotency.provider=postgresql")
.withBean("strayStore", IdempotencyStorePort.class, InMemoryIdempotencyStore::new)
.run(
context ->
assertThat(context).hasFailed().getFailure().hasStackTraceContaining("found 2"));
}
@Test
void theIdempotencyCompositionDoesNotOwnTheApplicationClock() {
assertThat(Arrays.stream(IdempotencyAutoConfiguration.class.getDeclaredMethods()))
.noneMatch(
method ->
method.getReturnType() == Clock.class && method.isAnnotationPresent(Bean.class));
}
private static Class<?> postgreSqlStoreConfig() {
try {
return Class.forName(POSTGRESQL_STORE_CONFIG);
} catch (ClassNotFoundException missing) {
throw new IllegalStateException(missing);
}
}
/** What the composition root once scanned, narrowed to the store package. */
@Configuration(proxyBeanMethods = false)
@ComponentScan("dev.caskeleton.adapter.outbound.persistence.idempotency.postgresql")
static class ScannedPersistence {}
}
@@ -0,0 +1,64 @@
package dev.caskeleton.composition.idempotency;
import static org.assertj.core.api.Assertions.assertThat;
import dev.caskeleton.adapter.outbound.support.startup.ModuleDefaultsEnvironmentPostProcessor;
import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.context.annotation.ImportCandidates;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.StandardEnvironment;
/**
* The module arrives with its own registration and settings, and a deployment's value beats them.
*/
class IdempotencyModuleDefaultsTest {
@Test
void theModuleRegistersItsAutoConfiguration() {
assertThat(ImportCandidates.load(AutoConfiguration.class, getClass().getClassLoader()))
.contains(IdempotencyAutoConfiguration.class.getName());
}
@Test
void theShippedDefaultsLeaveIdempotencyOff() {
// when
StandardEnvironment environment = processed(Map.of());
// then
assertThat(environment.getProperty("ca-skeleton.capabilities.idempotency.provider"))
.isEqualTo("disabled");
}
@Test
void theEnvironmentVariableSelectsTheProviderThroughTheShippedPlaceholder() {
// when
StandardEnvironment environment = processed(Map.of("APP_IDEMPOTENCY_PROVIDER", "postgresql"));
// then
assertThat(environment.getProperty("ca-skeleton.capabilities.idempotency.provider"))
.isEqualTo("postgresql");
}
@Test
void theShippedLifecycleKeysBindWithoutAStrayKey() {
// given
StandardEnvironment environment = processed(Map.of("APP_IDEMPOTENCY_PROVIDER", "redis"));
// when
IdempotencySettings settings = IdempotencySettings.bind(environment);
// then
assertThat(settings.responseCodecId()).isEqualTo("json-v2");
}
private static StandardEnvironment processed(Map<String, Object> deployment) {
StandardEnvironment environment = new StandardEnvironment();
environment.getPropertySources().addFirst(new MapPropertySource("deployment", deployment));
new ModuleDefaultsEnvironmentPostProcessor()
.postProcessEnvironment(environment, new SpringApplication());
return environment;
}
}
@@ -0,0 +1,189 @@
package dev.caskeleton.composition.idempotency;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.catchThrowable;
import dev.caskeleton.adapter.outbound.support.startup.StartupErrorCode;
import dev.caskeleton.adapter.outbound.support.startup.StartupFailureException;
import java.time.Duration;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.springframework.boot.context.properties.bind.BindException;
import org.springframework.mock.env.MockEnvironment;
class IdempotencySettingsTest {
private static final String PREFIX = "ca-skeleton.capabilities.idempotency.";
@Test
void absentLifecycleKeysBindToTheDocumentedDefaults() {
// given
MockEnvironment environment = new MockEnvironment().withProperty(PREFIX + "provider", "redis");
// when
IdempotencySettings settings = IdempotencySettings.bind(environment);
// then
assertThat(settings)
.usingRecursiveComparison()
.isEqualTo(
new IdempotencySettings(
IdempotencySettings.Provider.REDIS,
Duration.ofSeconds(30),
Duration.ofHours(24),
Duration.ofHours(24),
"json-v2",
2,
Duration.ofMinutes(10)));
}
@Test
void kebabCaseKeysBindEveryField() {
// given
MockEnvironment environment =
new MockEnvironment()
.withProperty(PREFIX + "provider", "postgresql")
.withProperty(PREFIX + "processing-lease", "45s")
.withProperty(PREFIX + "replay-ttl", "72h")
.withProperty(PREFIX + "failure-retention", "2h")
.withProperty(PREFIX + "response-codec-id", "json-v3")
.withProperty(PREFIX + "policy-revision", "3")
.withProperty(PREFIX + "reaper-interval", "1m");
// when
IdempotencySettings settings = IdempotencySettings.bind(environment);
// then
assertThat(settings)
.usingRecursiveComparison()
.isEqualTo(
new IdempotencySettings(
IdempotencySettings.Provider.POSTGRESQL,
Duration.ofSeconds(45),
Duration.ofHours(72),
Duration.ofHours(2),
"json-v3",
3,
Duration.ofMinutes(1)));
}
@Test
void anUnknownProviderFailsBinding() {
// given
MockEnvironment environment = new MockEnvironment().withProperty(PREFIX + "provider", "jdbc");
// when
Throwable thrown = catchThrowable(() -> IdempotencySettings.bind(environment));
// then
assertThat(thrown)
.isInstanceOf(BindException.class)
.hasStackTraceContaining("ca-skeleton.capabilities.idempotency.provider");
}
/**
* A misspelt lifecycle key used to bind to nothing and leave the default in force: {@code
* replay-tll=1h} ran with a 24-hour replay window.
*/
@Test
void aMisspeltLifecycleKeyFailsBindingInsteadOfLeavingTheDefaultInForce() {
// given
MockEnvironment environment =
new MockEnvironment()
.withProperty(PREFIX + "provider", "redis")
.withProperty(PREFIX + "replay-tll", "1h");
// when
Throwable thrown = catchThrowable(() -> IdempotencySettings.bind(environment));
// then
assertThat(thrown).isInstanceOf(BindException.class).hasStackTraceContaining("replay-tll");
}
@Test
void theRedisStoresOwnKeysUnderTheSharedPrefixAreLeftToTheStore() {
// given
MockEnvironment environment =
new MockEnvironment()
.withProperty(PREFIX + "provider", "redis")
.withProperty(PREFIX + "key-version", "1")
.withProperty(PREFIX + "command-timeout", "200ms");
// when
IdempotencySettings settings = IdempotencySettings.bind(environment);
// then
assertThat(settings.provider()).isEqualTo(IdempotencySettings.Provider.REDIS);
}
@ParameterizedTest
@DisplayName("an out-of-range duration is refused with its key and bound")
@CsvSource({
"PT0S, PT24H, PT24H, PT10M, processing-lease must be positive",
"PT61M, PT24H, PT24H, PT10M, processing-lease must be at most PT1H",
"PT30S, PT73H, PT24H, PT10M, replay-ttl must be at most PT72H",
"PT30S, -PT1H, PT24H, PT10M, replay-ttl must be positive",
"PT30S, PT24H, P31D, PT10M, failure-retention must be at most PT720H",
"PT30S, PT24H, PT24H, PT0S, reaper-interval must be positive"
})
void outOfRangeDurationIsRefused(
Duration lease, Duration replay, Duration retention, Duration reaper, String message) {
// when
Throwable thrown =
catchThrowable(
() ->
new IdempotencySettings(
IdempotencySettings.Provider.REDIS,
lease,
replay,
retention,
null,
null,
reaper));
// then
assertThat(thrown)
.isInstanceOfSatisfying(
StartupFailureException.class,
e -> assertThat(e.errorCode()).isEqualTo(StartupErrorCode.STARTUP_VALIDATION_FAILED))
.hasMessageContaining("ca-skeleton.capabilities.idempotency." + message);
}
@ParameterizedTest
@CsvSource({"'', response-codec-id must contain 1-64 characters", "' ', response-codec-id"})
void blankCodecIdIsRefused(String codecId, String message) {
// when
Throwable thrown =
catchThrowable(
() ->
new IdempotencySettings(
IdempotencySettings.Provider.REDIS, null, null, null, codecId, null, null));
// then
assertThat(thrown)
.isInstanceOfSatisfying(
StartupFailureException.class,
e -> assertThat(e.errorCode()).isEqualTo(StartupErrorCode.STARTUP_VALIDATION_FAILED))
.hasMessageContaining("ca-skeleton.capabilities.idempotency." + message);
}
@Test
void nonPositivePolicyRevisionIsRefused() {
// when
Throwable thrown =
catchThrowable(
() ->
new IdempotencySettings(
IdempotencySettings.Provider.REDIS, null, null, null, null, 0, null));
// then
assertThat(thrown)
.isInstanceOfSatisfying(
StartupFailureException.class,
e -> assertThat(e.errorCode()).isEqualTo(StartupErrorCode.STARTUP_VALIDATION_FAILED))
.hasMessageContaining(
"ca-skeleton.capabilities.idempotency.policy-revision must be positive");
}
}