ã¨ã ã¹ãªã¼ ã¨ã³ã¸ãã¢ã®å²©æ¬ã§ãã
ç¾å¨ç§ã®æå±ãã¦ãããã¼ã ã§ã¯ã以åä½æããã¢ã³ã±ã¼ããä½ãããã®ã·ã¹ãã ã®ãµã¼ããµã¤ããªãã¬ã¼ã¹ãæ¤è¨ãã¦ãã¾ãã ã¡ãªã¿ã«ã¯ã©ã¤ã¢ã³ããµã¤ãã¯ä¸è¨ã®ãã®ã§ãã
- æ¡ç¨ããæè¡
- ãªãQuarkus?
- SQLã¢ã¯ã»ã¹ã¯Doma
- è¨è¨æ¹éã¯CQRS
- ã¾ã¨ã
- We're hiring!
æ¡ç¨ããæè¡
以åã®ãµã¼ããµã¤ãã¯Javaã§ä½ããã¦ãããåå©ç¨å¯è½ãªæ¢åã®è³ç£ããããããJVMç³»ã®è¨èªãæ¤è¨ãã¦ãã¾ãã ä»ã®ã·ã¹ãã ã§ã¯Kotlin + SpringBootã使ã£ã¦ããããåæ§ã®æ§æãèããããã®ã§ããã SpringBootãéçºãã¦ãããã¡ã«éããªããèµ·åã«æ°åç§ãããããã«ãªãéçºã¹ãã¼ããé ããªã£ã¦ãã¾ã£ããã¨ã æ°ãããã®ã«ææ¦ãããã¨ããæè¡è ã®èããéè¦è¦ãã¦ãããããKotlin + Quarkus + Domaãæ¡ç¨ãããã¨ã«ãã¾ããã
ãªãQuarkus?
æè¿ã¯SpringBoot以å¤ã®FWãé¸æè¢ãããã¾ããKotlinã使ãããã¨ãããã¨ãèããã¨ãä¸è¨ã®é¸æè¢ããããã¾ããã
- Ktor
- Micronaut
- Helidon
- Quarkus
ããã§ãStaræ°ã®ä¼¸ã³ãè¦ã¦ã¿ãã¨ä¸è¨ã®ããã«ãªã£ã¦ãã¾ãã Star history ãããã®FWã伸ã³ã¦ãã¾ãããQuarkusã®ä¼¸ã³ãé 1ã¤æãã¦ãã¾ãã
å®éã«Quarkusã軽ã使ã£ã¦ã¿ãã¨ãã軽éã§ã使ãåæãæªãããã¾ããã§ããã
- 軽é
- OpenAPIãç°¡åã«ä½¿ãã
- SpringBootã¨ã»ã¼åãæ¸ãæ¹ãå¯è½ãªãããã¡ã³ãã¼ã®å¦ç¿ã³ã¹ããé«ããªã
- æè¡çã«æ°ãããã¨ã«ãã£ã¬ã³ã¸ããã
æ°ããFWãªã®ã§ãªã¹ã¯ã¯æãã¾ãããç¾ç¶ã®ãã¼ã å ã¯ãã¤ã¯ããµã¼ãã¹ã¢ã¼ããã¯ãã£ãæ¡ç¨ãã¦ããããã 1ã¤1ã¤ã®ã·ã¹ãã ã®ç²åº¦ã¯å°ããæãããã¦ãã¾ãããã®è¨è¨æ¹éã«ãã£ã¦ãªã¹ã¯ã¯æãããããQuarkusãé¸æãã¾ããã
- ã¢ã³ã±ã¼ãã®ç·¨éã¨åçç»é¢ãä»åã®ã·ã¹ãã ã®æ å½ç¯å²
- ãã®ä»ã®ã¨ã ã¹ãªã¼ã«ç¹åãã管çç»é¢ããã£ãã«é¨åã«é¢ãã¦ã¯å¥ã·ã¹ãã ã§æ§ç¯æ¸ã¿
SQLã¢ã¯ã»ã¹ã¯Doma
次ã®é¸æã¯SQLã§ä½¿ãã©ã¤ãã©ãªã§ããè¦ä»¶ã¨ãã¦ã¯ä»¥ä¸ã®ï¼ã¤ã§ãã
- è¤éãªSQLãããããã¨
- SQLãç°¡åã«ã³ã¼ãã¨ãããã³ã°ã§ãããã¨
ãããã®2way SQLãå®ç¾ãããã¨ããã¨æ°ãç®ã®è¯ãã©ã¤ãã©ãªã¯è¦ã¤ãããã ãã§ã«æ¡ç¨å®ç¸¾ãããDomaãé¸æãããã¨ã«ãªãã¾ããã
ãã ããQuarkusã¯ãªãã¬ã¯ã·ã§ã³ã使ã£ã¦ããã¨nativeã¢ã¼ãã§åãããã¨ãã§ããªãã¨ããåé¡ãããã¾ããã nativeã¢ã¼ãã§åããäºå®ã¯ãªãã®ã§ä»åã¯æ°ã«ããªããã¨ã«ãã¾ãã æ¤è¨¼ãã¦ãã¾ããããDomaã¯ãªãã¬ã¯ã·ã§ã³ã使ã£ã¦ããã®ã§ãnativeã¢ã¼ãã§ããããªãå¯è½æ§ãããã¾ãã
Domaã®è¨è¿°æ¹æ³
KotlinãDomaã§è¨è¿°ããå ´åã«ã¯ä¸è¨ã®ããã«ã³ã¼ããæ¸ãã¾ãã
AnnotationTarget.CLASS
ã¯ApplicationScoped::class
ãæå®ãã¦ãã¾ããããã¼ã¸ã§ã³2.27.0ãã使ããããã«ä¿®æ£ãã¦ãããã¾ããã
@Dao @AnnotateWith(annotations =[ Annotation(target = AnnotationTarget.CLASS, type = ApplicationScoped::class), Annotation(target = AnnotationTarget.CONSTRUCTOR, type = Inject::class) ]) interface SurveyDao { @Select fun selectById(id: String): SurveyDomaEntity? @Select fun selectByPublicId(publicId: String): SurveyDomaEntity? @Insert fun insert(entity: SurveyDomaEntity): Result<SurveyDomaEntity> @Update fun update(entity: SurveyDomaEntity): Result<SurveyDomaEntity> @Delete fun delete(entity: SurveyDomaEntity): Result<SurveyDomaEntity> }
ã¨ã³ãã£ãã£ã¯ä¸è¨ã®ããã«data classã§å®ç¾©ãã¾ãã
@Entity(immutable = true) @Table(name = "survey") data class SurveyDomaEntity( /** ID */ @Id @Column(name = "id") val id: String, ... )
Quarkus + Domaã§è¦ã¤ãã£ãåé¡
ã¾ããannotation processingã§çæãããDomaã®ã³ã¼ããJavaã§ãããããã³ã³ãã¤ã«ãããã¯ã©ã¹ã¯build/classes/java
ã«åºåããã¾ãã
ããããkotlinã¯build/classes/kotlin
ã«åºåããã¾ãããQuarkus v1.1.1ã§ã¯Quarkusãçæ¹ã®ã¯ã©ã¹ããã¿ã¦ãããªããã
Domaã®ã¯ã©ã¹ãè¦ã¤ãããªãã¨ããä¸å
·åãããã¾ããã
å½æãã§ã«Issueã¨ãã¦ä¸ãã£ã¦ããã®ã§ã ãã®ãã¡å¯¾å¿ãããã¯ãã¨ãããã¨ã§ãä¸è¨ã®å¯¾å¿ãbuild.gradleã«é©ç¨ãã¦ä¸å ·åãåé¿ãã¦ãã¾ãã
compileJava { doLast { // Quarkusã/build/classes/kotlin/mainããã¿ãªããããannotation processingããã¯ã©ã¹ãã³ãã¼ãã copy { from "$projectDir/build/classes/java/main" into "$projectDir/build/classes/kotlin/main" } File f = file("$projectDir/build/classes/java/main") f.deleteDir() } }
è¨è¨æ¹éã¯CQRS
ãã¼ã å ã§ä½æãã¦ããä»ã®ã·ã¹ãã ã§ã¯ãã¯ãªã¼ã³ã¢ã¼ããã¯ãã£ã®èãæ¹ãæ¡ç¨ãã¦ãã¾ãã æ´æ°ç³»ã«é¢ãã¦ã¯ãããç´å¾ãã¦ããã®ã§ãããåç §ç³»ã®å®è£ ãä¸æºã§ããã åç §ç³»ã§ã¯æ´æ°ç³»ã¨ã¯å¿ è¦ã¨ãªããã¼ã¿ãç°ãªããè¤éãªãã¼ã¿ã®çµåãå¿ è¦ã¨ãªãã¾ãã ããããç¾ç¶ã®ã¢ã¼ããã¯ãã£ã§ã¯æ´æ°ç³»ã§ä½¿ã£ã¦ããã¨ã³ãã£ãã£ã«ä¸åº¦ãããã³ã°ã åç §ç³»ã«å¿ è¦ãªå½¢ã¸æ´å½¢ãã¦åºåãã¦ãããå¿ è¦ä»¥ä¸ã«è¤éã ãªã¨æãã¦ãã¾ããã ããã§ãè¦ã¤ããã®ãä¸è¨ã®è¨äºã§ãã
ã¾ãã«ç§ãæãã¦ããä¸æºç¹ã解決ãã¦ããããã®ã§ãããè¨äºèªä½ã¯Microsoftã®ãã®ãªã®ã§ã C#ã§å ·ä½ä¾ãæ¸ããã¦ãã¾ãããèãæ¹ã¯è¨èªã«å¯ããªãã®ã§ããã®è¨è¨æ¹éãåèã«ã·ã¹ãã ãæ§ç¯ãã¦ãã¾ãã ãªãããã±ã¼ã¸ãåãããã¨ã§è¨è¨æ¹éãæ確ã«ãã¦ãã¾ãã
ããã±ã¼ã¸ | è¨è¨æ¹é |
---|---|
command | ã¯ãªã¼ã³ã¢ã¼ããã¯ãã£ã®èãæ¹ |
query | Domaã使ã£ã¦åºåå°ç¨ã®ã¢ãã«ãæ§ç¯ãã¦è¿ã |
ä»ã絶è³éçºä¸ã§ãããã¾ã®ã¨ããéçºããããç¶æ ããã¼ãã§ãã¦ãã¾ãã
ã¾ã¨ã
- ãã¤ã¯ããµã¼ãã¹ã¢ã¼ããã¯ãã£ãæ¡ç¨ãã¦ãããã¨ã§ãæ»ããã¢ã¼ããã¯ãã£ã®Kotlin + Quarkus + Domaãæ¡ç¨ãããã§ããã
- CQRSã§è¨è¨ãããåç §ç³»ãå¿å°ããéçºã§ãã¦ããã
We're hiring!
ã¨ã ã¹ãªã¼ã§ã¯Kotlinã§ãµã¼ããµã¤ãéçºããããã¨ã³ã¸ãã¢ãåéãã¦ãã¾ãã 社å¡ã¨ã«ã¸ã¥ã¢ã«ã«ã話ãããã¨ãã§ãã¾ãã®ã§ãèå³ãæãããæ¹ã¯ä¸è¨ãããåãåãããã ããã