-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
888 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Thumbs.db | ||
.DS_Store | ||
.gradle | ||
build/ | ||
target/ | ||
out/ | ||
.micronaut/ | ||
.idea | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.project | ||
.settings | ||
.classpath | ||
.factorypath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
@file:Suppress("UnstableApiUsage", "DSL_SCOPE_VIOLATION") | ||
|
||
plugins { | ||
kotlin("jvm") version libs.versions.kotlin | ||
id("org.jetbrains.kotlin.plugin.allopen") version libs.versions.kotlin | ||
kotlin("plugin.serialization") version libs.versions.kotlin | ||
application | ||
idea | ||
id("com.google.devtools.ksp") version "1.9.25-1.0.20" | ||
id("com.github.johnrengelman.shadow") version "8.1.1" | ||
id("io.micronaut.application") version "4.4.3" | ||
id("io.micronaut.aot") version "4.4.3" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots") } | ||
} | ||
|
||
dependencies { | ||
runtimeOnly("org.yaml:snakeyaml:2.1") | ||
implementation(platform("io.micronaut.platform:micronaut-parent:4.7.1")) | ||
ksp("io.micronaut:micronaut-http-validation") | ||
ksp("io.micronaut.serde:micronaut-serde-processor") | ||
implementation("io.micronaut.kotlin:micronaut-kotlin-runtime") | ||
implementation("io.micronaut.serde:micronaut-serde-jackson") | ||
implementation("io.micronaut:micronaut-http-client") | ||
implementation("io.micronaut:micronaut-http-server-netty") | ||
implementation("io.micronaut:micronaut-inject") | ||
implementation("io.micronaut:micronaut-core") | ||
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin") | ||
implementation("com.couchbase.client:metrics-micrometer:0.7.5") | ||
implementation("io.micronaut.configuration:micronaut-micrometer-core:1.3.1") | ||
implementation("org.apache.kafka:kafka-clients") | ||
implementation(libs.kotlinx.reactor) | ||
implementation(libs.kotlinx.core) | ||
implementation(libs.kotlinx.reactive) | ||
implementation(libs.couchbase.client) | ||
implementation(libs.couchbase.client.metrics) | ||
implementation(libs.jackson.kotlin) | ||
implementation(libs.kotlinx.slf4j) | ||
} | ||
|
||
dependencies { | ||
testImplementation(libs.kotest.property) | ||
testImplementation(libs.kotest.runner.junit5) | ||
testImplementation(projects.stove.lib.stoveTestingE2eHttp) | ||
testImplementation(projects.stove.lib.stoveTestingE2eWiremock) | ||
testImplementation(projects.stove.lib.stoveTestingE2eCouchbase) | ||
testImplementation(projects.stove.lib.stoveTestingE2eElasticsearch) | ||
testImplementation(projects.stove.starters.micronautStarter.stoveMicronautTestingE2e) | ||
} | ||
|
||
application { | ||
mainClass = "stove.micronaut.example.ApplicationKt" | ||
} | ||
|
||
graalvmNative.toolchainDetection = false | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.toVersion("17") | ||
} | ||
|
||
micronaut { | ||
runtime("netty") | ||
testRuntime("kotest5") | ||
processing { | ||
incremental(true) | ||
annotations("stove.micronaut.example.*") | ||
} | ||
aot { | ||
optimizeServiceLoading = false | ||
convertYamlToJava = false | ||
precomputeOperations = true | ||
cacheEnvironment = true | ||
optimizeClassLoading = true | ||
deduceEnvironment = true | ||
optimizeNetty = true | ||
replaceLogbackXml = true | ||
} | ||
} |
Binary file not shown.
7 changes: 7 additions & 0 deletions
7
examples/micronaut-example/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
28 changes: 28 additions & 0 deletions
28
examples/micronaut-example/src/main/kotlin/stove/micronaut/example/Application.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package stove.micronaut.example | ||
|
||
import io.micronaut.context.ApplicationContext | ||
import io.micronaut.runtime.EmbeddedApplication | ||
|
||
fun main(args: Array<String>) { | ||
run(args) | ||
} | ||
|
||
fun run( | ||
args: Array<String>, | ||
init: ApplicationContext.() -> Unit = {} | ||
): ApplicationContext { | ||
val context = ApplicationContext | ||
.builder() | ||
.args(*args) | ||
.build() | ||
.also(init) | ||
.start() | ||
|
||
context.findBean(EmbeddedApplication::class.java).ifPresent { app -> | ||
if (!app.isRunning) { | ||
app.start() | ||
} | ||
} | ||
|
||
return context | ||
} |
26 changes: 26 additions & 0 deletions
26
...s/micronaut-example/src/main/kotlin/stove/micronaut/example/application/domain/Product.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package stove.micronaut.example.application.domain | ||
|
||
import io.micronaut.serde.annotation.Serdeable | ||
import java.util.* | ||
|
||
@Serdeable | ||
data class Product( | ||
val id: String, | ||
val name: String, | ||
val supplierId: Long, | ||
val isBlacklist: Boolean, | ||
val createdDate: Date | ||
) { | ||
companion object { | ||
|
||
fun new(id: String, name: String, supplierId: Long, isBlacklist: Boolean): Product { | ||
return Product( | ||
id = id, | ||
name = name, | ||
supplierId = supplierId, | ||
createdDate = Date(), | ||
isBlacklist = isBlacklist | ||
) | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ample/src/main/kotlin/stove/micronaut/example/application/repository/ProductRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package stove.micronaut.example.application.repository | ||
|
||
import stove.micronaut.example.application.domain.Product | ||
|
||
interface ProductRepository { | ||
suspend fun save(product: Product): Product | ||
suspend fun findById(id: Long): Product? | ||
} |
19 changes: 19 additions & 0 deletions
19
...ut-example/src/main/kotlin/stove/micronaut/example/application/services/ProductService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package stove.micronaut.example.application.services | ||
|
||
import jakarta.inject.Singleton | ||
import stove.micronaut.example.application.domain.Product | ||
import stove.micronaut.example.application.repository.ProductRepository | ||
import stove.micronaut.example.infrastructure.http.SupplierHttpService | ||
|
||
@Singleton | ||
class ProductService( | ||
private val productRepository: ProductRepository, | ||
private val supplierHttpService: SupplierHttpService | ||
) { | ||
suspend fun createProduct(id: String, productName: String, supplierId: Long): Product { | ||
val supplier = supplierHttpService.getSupplierPermission(supplierId) | ||
val product = Product.new(id, productName, supplierId, supplier!!.isBlacklisted) | ||
productRepository.save(product) | ||
return product | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...t-example/src/main/kotlin/stove/micronaut/example/application/services/SupplierService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package stove.micronaut.example.application.services | ||
|
||
import io.micronaut.serde.annotation.Serdeable | ||
|
||
@Serdeable | ||
data class SupplierPermission( | ||
val id: Long, | ||
val isBlacklisted: Boolean | ||
) | ||
|
||
interface SupplierService { | ||
suspend fun getSupplierPermission(supplierId: Long): SupplierPermission? | ||
} |
25 changes: 25 additions & 0 deletions
25
...t-example/src/main/kotlin/stove/micronaut/example/infrastructure/api/ProductController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package stove.micronaut.example.infrastructure.api | ||
|
||
import io.micronaut.http.annotation.* | ||
import stove.micronaut.example.application.domain.Product | ||
import stove.micronaut.example.application.services.ProductService | ||
import stove.micronaut.example.infrastructure.api.model.request.CreateProductRequest | ||
|
||
@Controller("/products") | ||
class ProductController( | ||
private val productService: ProductService | ||
) { | ||
@Get("/index") | ||
fun get( | ||
@QueryValue keyword: String = "default" | ||
): String = "Hi from Stove framework with $keyword" | ||
|
||
@Post("/create") | ||
suspend fun createProduct( | ||
@Body request: CreateProductRequest | ||
): Product = productService.createProduct( | ||
id = request.id, | ||
productName = request.name, | ||
supplierId = request.supplierId | ||
) | ||
} |
10 changes: 10 additions & 0 deletions
10
...n/kotlin/stove/micronaut/example/infrastructure/api/model/request/CreateProductRequest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package stove.micronaut.example.infrastructure.api.model.request | ||
|
||
import io.micronaut.serde.annotation.Serdeable | ||
|
||
@Serdeable | ||
data class CreateProductRequest( | ||
val id: String, | ||
val name: String, | ||
val supplierId: Long | ||
) |
Oops, something went wrong.