Skip to content

Commit 9088a25

Browse files
authored
refactor: replace word transaction to saga (#120)
* refactor: replace word transaction to saga * build: netx version 0.3.8 to 0.3.9
1 parent 3134d93 commit 9088a25

81 files changed

Lines changed: 1721 additions & 1709 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 108 additions & 106 deletions
Large diffs are not rendered by default.

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.rooftop.netx
5-
version=0.3.8
5+
version=0.3.9
66
compatibility=17
77

88
### Sonarcloud ###

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ class EncodeException(message: String, throwable: Throwable) : RuntimeException(
44

55
class DecodeException(message: String, throwable: Throwable) : RuntimeException(message, throwable)
66

7-
open class TransactionException(message: String) : RuntimeException(message)
7+
open class SagaException(message: String) : RuntimeException(message)
88

9-
class AlreadyCommittedTransactionException(transactionId: String, state: String) :
10-
TransactionException("Cannot join transaction cause, transaction \"$transactionId\" already \"$state\"")
9+
class AlreadyCommittedSagaException(id: String, state: String) :
10+
SagaException("Cannot join saga cause, saga \"$id\" already \"$state\"")
1111

1212
class NotFoundDispatchFunctionException(message: String) : RuntimeException(message)
1313

14-
class FailedAckTransactionException(message: String) : RuntimeException(message)
14+
class FailedAckSagaException(message: String) : RuntimeException(message)
1515

1616
class ResultTimeoutException(message: String, throwable: Throwable) :
1717
RuntimeException(message, throwable)

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import reactor.core.publisher.Mono
44

55
interface Orchestrator<T : Any, V : Any> {
66

7-
fun transaction(request: T): Mono<Result<V>>
7+
fun saga(request: T): Mono<Result<V>>
88

9-
fun transaction(timeoutMillis: Long, request: T): Mono<Result<V>>
9+
fun saga(timeoutMillis: Long, request: T): Mono<Result<V>>
1010

11-
fun transaction(request: T, context: MutableMap<String, Any>): Mono<Result<V>>
11+
fun saga(request: T, context: MutableMap<String, Any>): Mono<Result<V>>
1212

13-
fun transaction(timeoutMillis: Long, request: T, context: MutableMap<String, Any>): Mono<Result<V>>
13+
fun saga(timeoutMillis: Long, request: T, context: MutableMap<String, Any>): Mono<Result<V>>
1414

15-
fun transactionSync(request: T): Result<V>
15+
fun sagaSync(request: T): Result<V>
1616

17-
fun transactionSync(timeoutMillis: Long, request: T): Result<V>
17+
fun sagaSync(timeoutMillis: Long, request: T): Result<V>
1818

19-
fun transactionSync(request: T, context: MutableMap<String, Any>): Result<V>
19+
fun sagaSync(request: T, context: MutableMap<String, Any>): Result<V>
2020

21-
fun transactionSync(timeoutMillis: Long, request: T, context: MutableMap<String, Any>): Result<V>
21+
fun sagaSync(timeoutMillis: Long, request: T, context: MutableMap<String, Any>): Result<V>
2222
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.rooftop.netx.api
2+
3+
class SagaCommitEvent internal constructor(
4+
id: String,
5+
nodeName: String,
6+
group: String,
7+
event: String?,
8+
codec: Codec,
9+
) : SagaEvent(id, nodeName, group, event, codec) {
10+
11+
override fun copy(): SagaCommitEvent =
12+
SagaCommitEvent(id, nodeName, group, event, codec)
13+
}

src/main/kotlin/org/rooftop/netx/api/TransactionCommitListener.kt renamed to src/main/kotlin/org/rooftop/netx/api/SagaCommitListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlin.reflect.KClass
44

55
@Target(AnnotationTarget.FUNCTION)
66
@Retention(AnnotationRetention.RUNTIME)
7-
annotation class TransactionCommitListener(
7+
annotation class SagaCommitListener(
88
val event: KClass<*> = Any::class,
99
val noRollbackFor: Array<KClass<out Throwable>> = [],
1010
)

src/main/kotlin/org/rooftop/netx/api/TransactionEvent.kt renamed to src/main/kotlin/org/rooftop/netx/api/SagaEvent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package org.rooftop.netx.api
22

33
import kotlin.reflect.KClass
44

5-
sealed class TransactionEvent(
6-
val transactionId: String,
5+
sealed class SagaEvent(
6+
val id: String,
77
val nodeName: String,
88
val group: String,
99
internal val event: String?,
@@ -24,5 +24,5 @@ sealed class TransactionEvent(
2424
type
2525
)
2626

27-
internal abstract fun copy(): TransactionEvent
27+
internal abstract fun copy(): SagaEvent
2828
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.rooftop.netx.api
2+
3+
class SagaJoinEvent internal constructor(
4+
id: String,
5+
nodeName: String,
6+
group: String,
7+
event: String?,
8+
codec: Codec,
9+
) : SagaEvent(id, nodeName, group, event, codec) {
10+
11+
override fun copy(): SagaJoinEvent =
12+
SagaJoinEvent(id, nodeName, group, event, codec)
13+
}

src/main/kotlin/org/rooftop/netx/api/TransactionJoinListener.kt renamed to src/main/kotlin/org/rooftop/netx/api/SagaJoinListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import kotlin.reflect.KClass
44

55
@Target(AnnotationTarget.FUNCTION)
66
@Retention(AnnotationRetention.RUNTIME)
7-
annotation class TransactionJoinListener(
7+
annotation class SagaJoinListener(
88
val event: KClass<*> = Any::class,
99
val noRollbackFor: Array<KClass<out Throwable>> = [],
1010
val successWith: SuccessWith = SuccessWith.PUBLISH_JOIN,
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package org.rooftop.netx.api
2+
3+
import reactor.core.publisher.Mono
4+
5+
interface SagaManager {
6+
7+
fun start(): Mono<String>
8+
9+
fun <T : Any> start(event: T): Mono<String>
10+
11+
fun syncStart(): String
12+
13+
fun <T : Any> syncStart(event: T): String
14+
15+
fun join(id: String): Mono<String>
16+
17+
fun <T : Any> join(id: String, event: T): Mono<String>
18+
19+
fun syncJoin(id: String): String
20+
21+
fun <T : Any> syncJoin(id: String, event: T): String
22+
23+
fun exists(id: String): Mono<String>
24+
25+
fun syncExists(id: String): String
26+
27+
fun commit(id: String): Mono<String>
28+
29+
fun <T : Any> commit(id: String, event: T): Mono<String>
30+
31+
fun syncCommit(id: String): String
32+
33+
fun <T : Any> syncCommit(id: String, event: T): String
34+
35+
fun rollback(id: String, cause: String): Mono<String>
36+
37+
fun <T : Any> rollback(id: String, cause: String, event: T): Mono<String>
38+
39+
fun syncRollback(id: String, cause: String): String
40+
41+
fun <T : Any> syncRollback(id: String, cause: String, event: T): String
42+
43+
}

0 commit comments

Comments
 (0)