Skip to content

Commit

Permalink
refactor: Catch toOrchestrateEvent's exception (#136)
Browse files Browse the repository at this point in the history
* refactor: Catch toOrchestrateEvent's exception

* refactor: version 0.4.1 to 0.4.2
  • Loading branch information
devxb authored Apr 7, 2024
1 parent a03b664 commit 5fd082f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<br>

![version 0.4.1](https://img.shields.io/badge/version-0.4.1-black?labelColor=black&style=flat-square) ![jdk 17](https://img.shields.io/badge/minimum_jdk-17-orange?labelColor=black&style=flat-square) ![load-test](https://img.shields.io/badge/load%20test%2010%2C000%2C000-success-brightgreen?labelColor=black&style=flat-square)
![version 0.4.2](https://img.shields.io/badge/version-0.4.2-black?labelColor=black&style=flat-square) ![jdk 17](https://img.shields.io/badge/minimum_jdk-17-orange?labelColor=black&style=flat-square) ![load-test](https://img.shields.io/badge/load%20test%2010%2C000%2C000-success-brightgreen?labelColor=black&style=flat-square)
![redis--stream](https://img.shields.io/badge/-redis--stream-da2020?style=flat-square&logo=Redis&logoColor=white)

**TPS(6,000)** on my Macbook air m2(default options). _[link](#Test1-TPS)_
Expand Down Expand Up @@ -89,13 +89,13 @@ class OrderService(private val orderOrchestrator: Orchestrator<Order, OrderRespo

// Register Orchestrator
@Configurer
class OrchestratorConfigurer {

private val orchestratorFactory = OrchestratorFactory.instance()
class OrchestratorConfigurer(
private val orchestratorFactory: OrchestratorFactory,
) {

@Bean
fun orderOrchestartor(): Orchestrator<Order, OrderResponse> { // <First Request, Last Response>
return orchestratorFactory.create("orderOrchestrator")
return orchestratorFactory.create<Order>("orderOrchestrator")
.start(
orchestrate = { order -> // its order type
// Do your bussiness logic
Expand Down Expand Up @@ -125,7 +125,7 @@ class OrchestratorConfigurer {
throw IllegalArgumentException("Oops! Something went wrong..")
},
rollback = { request ->
...
// ...
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ kotlin.code.style=official

### Project ###
group=org.rooftopmsa
version=0.4.1
version=0.4.2
compatibility=17

### Sonarcloud ###
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/org/rooftop/netx/api/Orchestrator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import reactor.core.publisher.Mono
*
* }
*
* class OrderOrchestratorConfigurer {
*
* private val orchestratorFactory = OrchestratorFactory.instance()
* class OrderOrchestratorConfigurer(
* private val orchestratorFactory: OrchestratorFactory,
* ){
*
* fun orderOrchestrator(): Orchestrator<OrderRequest, Order> {
* return orchestratorFactory.create<OrderRequest>("orderOrchestrator")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.rooftop.netx.engine.listen

import org.rooftop.netx.api.*
import org.rooftop.netx.api.Context
import org.rooftop.netx.api.SagaEvent
import org.rooftop.netx.api.SagaManager
import org.rooftop.netx.api.TypeReference
import org.rooftop.netx.core.Codec
import org.rooftop.netx.engine.OrchestrateEvent
import org.rooftop.netx.engine.RequestHolder
Expand Down Expand Up @@ -64,17 +67,18 @@ internal abstract class AbstractOrchestrateListener<T : Any, V : Any> internal c
}
.flatMap { (request, event) -> command(request, event) }
.setNextCastableType()
.toOrchestrateEvent()
.map {
sagaEvent.setNextEvent(it)
}
.doOnError {
it.printStackTrace()
rollback(
sagaEvent.id,
it,
sagaEvent.decodeEvent(OrchestrateEvent::class)
)
}
.toOrchestrateEvent()
.map {
sagaEvent.setNextEvent(it)
}
}

protected open fun command(request: T, event: OrchestrateEvent): Mono<Pair<V, Context>> {
Expand Down

0 comments on commit 5fd082f

Please sign in to comment.