-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Bind values to context in Orchestrator (#106)
* refactor: Orchestrate와 Rollback 인터페이스에 Function을 제거한다 * feat: Context binding in orchestrator * docs: Netx version 0.3.3 to 0.3.4
- Loading branch information
Showing
31 changed files
with
789 additions
and
252 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
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 org.rooftop.netx.api | ||
|
||
import kotlin.reflect.KClass | ||
|
||
data class Context internal constructor( | ||
private val codec: Codec, | ||
internal val contexts: MutableMap<String, String>, | ||
) { | ||
|
||
fun <T : Any> set(key: String, value: T) { | ||
contexts[key] = codec.encode(value) | ||
} | ||
|
||
fun <T : Any> decodeContext(key: String, type: Class<T>): T = decodeContext(key, type.kotlin) | ||
|
||
fun <T : Any> decodeContext(key: String, type: KClass<T>): T = contexts[key]?.let { | ||
codec.decode(it, type) | ||
} ?: throw NullPointerException("Cannot find context by key \"$key\"") | ||
} |
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,6 @@ | ||
package org.rooftop.netx.api | ||
|
||
fun interface ContextOrchestrate<T : Any, V : Any> { | ||
|
||
fun orchestrate(context: Context, request: T): V | ||
} |
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,6 @@ | ||
package org.rooftop.netx.api | ||
|
||
fun interface ContextRollback<T : Any, V : Any?> { | ||
|
||
fun rollback(context: Context, request: T): V | ||
} |
2 changes: 1 addition & 1 deletion
2
...g/rooftop/netx/api/OrchestrateFunction.kt → ...otlin/org/rooftop/netx/api/Orchestrate.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package org.rooftop.netx.api | ||
|
||
fun interface OrchestrateFunction<T : Any, V : Any> { | ||
fun interface Orchestrate<T : Any, V : Any> { | ||
|
||
fun orchestrate(request: T): V | ||
} |
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
2 changes: 1 addition & 1 deletion
2
.../org/rooftop/netx/api/RollbackFunction.kt → ...n/kotlin/org/rooftop/netx/api/Rollback.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package org.rooftop.netx.api | ||
|
||
fun interface RollbackFunction<T : Any, V : Any?> { | ||
fun interface Rollback<T : Any, V : Any?> { | ||
|
||
fun rollback(request: T): V | ||
} |
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,14 @@ | ||
package org.rooftop.netx.api | ||
|
||
import java.lang.reflect.ParameterizedType | ||
import java.lang.reflect.Type | ||
|
||
|
||
abstract class TypeReference<T : Any>() { | ||
val type: Type | ||
|
||
init { | ||
val superClass: Type = this.javaClass.genericSuperclass | ||
type = (superClass as ParameterizedType).actualTypeArguments[0] | ||
} | ||
} |
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
Oops, something went wrong.