Skip to content

Commit 5fd082f

Browse files
authored
refactor: Catch toOrchestrateEvent's exception (#136)
* refactor: Catch toOrchestrateEvent's exception * refactor: version 0.4.1 to 0.4.2
1 parent a03b664 commit 5fd082f

4 files changed

Lines changed: 19 additions & 15 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<br>
66

7-
![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)
7+
![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)
88
![redis--stream](https://img.shields.io/badge/-redis--stream-da2020?style=flat-square&logo=Redis&logoColor=white)
99

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

9090
// Register Orchestrator
9191
@Configurer
92-
class OrchestratorConfigurer {
93-
94-
private val orchestratorFactory = OrchestratorFactory.instance()
92+
class OrchestratorConfigurer(
93+
private val orchestratorFactory: OrchestratorFactory,
94+
) {
9595

9696
@Bean
9797
fun orderOrchestartor(): Orchestrator<Order, OrderResponse> { // <First Request, Last Response>
98-
return orchestratorFactory.create("orderOrchestrator")
98+
return orchestratorFactory.create<Order>("orderOrchestrator")
9999
.start(
100100
orchestrate = { order -> // its order type
101101
// Do your bussiness logic
@@ -125,7 +125,7 @@ class OrchestratorConfigurer {
125125
throw IllegalArgumentException("Oops! Something went wrong..")
126126
},
127127
rollback = { request ->
128-
...
128+
// ...
129129
}
130130
)
131131
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ kotlin.code.style=official
22

33
### Project ###
44
group=org.rooftopmsa
5-
version=0.4.1
5+
version=0.4.2
66
compatibility=17
77

88
### Sonarcloud ###

src/main/kotlin/org/rooftop/netx/api/Orchestrator.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ import reactor.core.publisher.Mono
2626
*
2727
* }
2828
*
29-
* class OrderOrchestratorConfigurer {
30-
*
31-
* private val orchestratorFactory = OrchestratorFactory.instance()
29+
* class OrderOrchestratorConfigurer(
30+
* private val orchestratorFactory: OrchestratorFactory,
31+
* ){
3232
*
3333
* fun orderOrchestrator(): Orchestrator<OrderRequest, Order> {
3434
* return orchestratorFactory.create<OrderRequest>("orderOrchestrator")

src/main/kotlin/org/rooftop/netx/engine/listen/AbstractOrchestrateListener.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package org.rooftop.netx.engine.listen
22

3-
import org.rooftop.netx.api.*
3+
import org.rooftop.netx.api.Context
4+
import org.rooftop.netx.api.SagaEvent
5+
import org.rooftop.netx.api.SagaManager
6+
import org.rooftop.netx.api.TypeReference
47
import org.rooftop.netx.core.Codec
58
import org.rooftop.netx.engine.OrchestrateEvent
69
import org.rooftop.netx.engine.RequestHolder
@@ -64,17 +67,18 @@ internal abstract class AbstractOrchestrateListener<T : Any, V : Any> internal c
6467
}
6568
.flatMap { (request, event) -> command(request, event) }
6669
.setNextCastableType()
70+
.toOrchestrateEvent()
71+
.map {
72+
sagaEvent.setNextEvent(it)
73+
}
6774
.doOnError {
75+
it.printStackTrace()
6876
rollback(
6977
sagaEvent.id,
7078
it,
7179
sagaEvent.decodeEvent(OrchestrateEvent::class)
7280
)
7381
}
74-
.toOrchestrateEvent()
75-
.map {
76-
sagaEvent.setNextEvent(it)
77-
}
7882
}
7983

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

0 commit comments

Comments
 (0)