Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
fix: Move reactive usecase to be a child of factory/command usecases.
Browse files Browse the repository at this point in the history
Signed-off-by: Ibrahim AlTamimi <ibm.iloom@gmail.com>
  • Loading branch information
ibm-iloom committed Feb 27, 2021
1 parent fac4b29 commit 2b51974
Show file tree
Hide file tree
Showing 38 changed files with 81 additions and 71 deletions.
2 changes: 1 addition & 1 deletion ktx-radix-adapter/ktx-radix-adapter-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-adapter</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/ktx-radix-development-shared/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/ktx-radix-development-store/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>ktx-radix-development-usecase-reactive</artifactId>
<dependencies>
<dependency>
<groupId>${project.parent.groupId}</groupId>
<artifactId>ktx-radix-development-usecase</artifactId>
<artifactId>ktx-radix-development-usecase-adapter</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quee.ktx.radix.usecase.reactive.command

import io.quee.ktx.radix.develop.usecase.CommandUseCase
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import reactor.core.publisher.Flux

Expand All @@ -8,6 +10,4 @@ import reactor.core.publisher.Flux
* Created At 12, **Fri February, 2021**
* Project *ktx-radix* [Quee.IO]
*/
interface ReactiveFluxCommandUseCase<RQ : UseCaseRequest> {
fun Flux<RQ>.execute()
}
interface ReactiveFluxCommandUseCase<RQ : UseCaseRequest> : CommandUseCase<RequestAdapter<Flux<RQ>>>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quee.ktx.radix.usecase.reactive.command

import io.quee.ktx.radix.develop.usecase.CommandUseCase
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import reactor.core.publisher.Mono

Expand All @@ -8,6 +10,4 @@ import reactor.core.publisher.Mono
* Created At 12, **Fri February, 2021**
* Project *ktx-radix* [Quee.IO]
*/
interface ReactiveMonoCommandUseCase<RQ : UseCaseRequest> {
fun Mono<RQ>.execute()
}
interface ReactiveMonoCommandUseCase<RQ : UseCaseRequest> : CommandUseCase<RequestAdapter<Mono<RQ>>>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quee.ktx.radix.usecase.reactive.command

import io.quee.ktx.radix.develop.usecase.adapter.adapterExecute
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import reactor.kotlin.core.publisher.toFlux
import reactor.kotlin.core.publisher.toMono
Expand All @@ -9,9 +10,8 @@ import reactor.kotlin.core.publisher.toMono
* Created At 12, **Fri February, 2021**
* Project *ktx-radix* [Quee.IO]
*/

infix fun <RQ : UseCaseRequest> ReactiveFluxCommandUseCase<RQ>.execute(request: RQ) =
listOf(request).toFlux().execute()
adapterExecute(listOf(request).toFlux())

infix fun <RQ : UseCaseRequest> ReactiveMonoCommandUseCase<RQ>.execute(request: RQ) =
request.toMono().execute()
adapterExecute(request.toMono())
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quee.ktx.radix.usecase.reactive.functional

import io.quee.ktx.radix.develop.usecase.FunctionalUseCase
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.adapter.ResponseAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse
import reactor.core.publisher.Flux
Expand All @@ -9,6 +12,5 @@ import reactor.core.publisher.Flux
* Created At 12, **Fri February, 2021**
* Project *ktx-radix* [Quee.IO]
*/
interface ReactiveFluxFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse> {
fun Flux<RQ>.process(): Flux<RS>
}
interface ReactiveFluxFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse> :
FunctionalUseCase<RequestAdapter<Flux<RQ>>, ResponseAdapter<Flux<RS>>>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package io.quee.ktx.radix.usecase.reactive.functional

import io.quee.ktx.radix.develop.usecase.FunctionalUseCase
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.adapter.ResponseAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse
import reactor.core.publisher.Mono
Expand All @@ -9,6 +12,5 @@ import reactor.core.publisher.Mono
* Created At 12, **Fri February, 2021**
* Project *ktx-radix* [Quee.IO]
*/
interface ReactiveMonoFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse> {
fun Mono<RQ>.process(): Mono<RS>
}
interface ReactiveMonoFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse> :
FunctionalUseCase<RequestAdapter<Mono<RQ>>, ResponseAdapter<Mono<RS>>>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quee.ktx.radix.usecase.reactive.functional

import io.quee.ktx.radix.develop.usecase.adapter.adapterProcess
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse
import reactor.kotlin.core.publisher.toFlux
Expand All @@ -15,7 +16,7 @@ infix fun <RQ : UseCaseRequest, RS : UseCaseResponse> ReactiveFluxFunctionalUseC
this process listOf(request)

infix fun <RQ : UseCaseRequest, RS : UseCaseResponse> ReactiveFluxFunctionalUseCase<RQ, RS>.process(request: Iterable<RQ>) =
request.toFlux().process()
adapterProcess(request.toFlux())

infix fun <RQ : UseCaseRequest, RS : UseCaseResponse> ReactiveMonoFunctionalUseCase<RQ, RS>.process(request: RQ) =
request.toMono().process()
adapterProcess(request.toMono())
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quee.ktx.radix.develop.usecase.validation.command

import io.quee.ktx.radix.develop.usecase.actionable.Actionable
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.validation.func.DefaultUseCaseValidator
import io.quee.ktx.radix.develop.usecase.validation.func.UseCaseValidator
Expand All @@ -14,18 +15,18 @@ import reactor.core.publisher.Flux
* Project *ktx-radix* [Quee.IO]
*/
abstract class ValidationReactiveFluxCommandUseCase<RQ : UseCaseRequest>(
private val validator: UseCaseValidator = DefaultUseCaseValidator.create()
private val validator: UseCaseValidator = DefaultUseCaseValidator.create(),
) : ReactiveFluxCommandUseCase<RQ>, Actionable<RQ, Unit> {
final override fun RQ.before() = validator validate this

override fun RQ.after(response: Unit) = Unit

final override fun Flux<RQ>.execute() =
with(this) {
this.map {
override fun RequestAdapter<Flux<RQ>>.execute() {
with(request) {
map {
it.apply { before() }
}.doExecute()
}
}

abstract fun Flux<RQ>.doExecute()
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quee.ktx.radix.develop.usecase.validation.command

import io.quee.ktx.radix.develop.usecase.actionable.Actionable
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.validation.func.DefaultUseCaseValidator
import io.quee.ktx.radix.develop.usecase.validation.func.UseCaseValidator
Expand All @@ -14,14 +15,13 @@ import reactor.core.publisher.Mono
* Project *ktx-radix* [Quee.IO]
*/
abstract class ValidationReactiveMonoCommandUseCase<RQ : UseCaseRequest>(
private val validator: UseCaseValidator = DefaultUseCaseValidator.create()
private val validator: UseCaseValidator = DefaultUseCaseValidator.create(),
) : ReactiveMonoCommandUseCase<RQ>, Actionable<RQ, Unit> {
final override fun RQ.before() = validator validate this

override fun RQ.after(response: Unit) = Unit

final override fun Mono<RQ>.execute() =
with(this) {
override fun RequestAdapter<Mono<RQ>>.execute() =
with(request) {
this.map {
it.apply { before() }
}.doExecute()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quee.ktx.radix.develop.usecase.validation.functional

import io.quee.ktx.radix.develop.usecase.actionable.Actionable
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.adapter.toResponse
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse
import io.quee.ktx.radix.develop.usecase.validation.func.DefaultUseCaseValidator
Expand All @@ -15,17 +17,18 @@ import reactor.core.publisher.Flux
* Project *ktx-radix* [Quee.IO]
*/
abstract class ValidationReactiveFluxFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse>(
private val validator: UseCaseValidator = DefaultUseCaseValidator.create()
private val validator: UseCaseValidator = DefaultUseCaseValidator.create(),
) : ReactiveFluxFunctionalUseCase<RQ, RS>, Actionable<RQ, RS> {
final override fun RQ.before() = validator validate this

override fun RQ.after(response: RS) = Unit

override fun Flux<RQ>.process() =
with(this) {
this.map {
it.apply { before() }
}.doProcess()
override fun RequestAdapter<Flux<RQ>>.process() =
with(request) {
toResponse {
map {
it.apply { before() }
}.doProcess()
}
}

abstract fun Flux<RQ>.doProcess(): Flux<RS>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package io.quee.ktx.radix.develop.usecase.validation.functional

import io.quee.ktx.radix.develop.usecase.actionable.Actionable
import io.quee.ktx.radix.develop.usecase.adapter.RequestAdapter
import io.quee.ktx.radix.develop.usecase.adapter.toResponse
import io.quee.ktx.radix.develop.usecase.model.UseCaseRequest
import io.quee.ktx.radix.develop.usecase.model.UseCaseResponse
import io.quee.ktx.radix.develop.usecase.validation.func.DefaultUseCaseValidator
Expand All @@ -15,17 +17,18 @@ import reactor.core.publisher.Mono
* Project *ktx-radix* [Quee.IO]
*/
abstract class ValidationReactiveMonoFunctionalUseCase<RQ : UseCaseRequest, RS : UseCaseResponse>(
private val validator: UseCaseValidator = DefaultUseCaseValidator.create()
private val validator: UseCaseValidator = DefaultUseCaseValidator.create(),
) : ReactiveMonoFunctionalUseCase<RQ, RS>, Actionable<RQ, RS> {
final override fun RQ.before() = validator validate this

override fun RQ.after(response: RS) = Unit

final override fun Mono<RQ>.process() =
with(this) {
this.map {
it.apply { before() }
}.doProcess()
override fun RequestAdapter<Mono<RQ>>.process() =
with(request) {
toResponse {
map {
it.apply { before() }
}.doProcess()
}
}

abstract fun Mono<RQ>.doProcess(): Mono<RS>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ import io.quee.ktx.radix.develop.usecase.validation.func.UseCaseValidator
* Project *ktx-radix* [Quee.IO]
*/

infix fun <RQ : UseCaseRequest> UseCaseValidator.validate(request: RQ) {
request.validate()
}
infix fun <RQ : UseCaseRequest> UseCaseValidator.validate(request: RQ) = request.validate()
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-development</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-development/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ktx-radix-port/ktx-radix-port-logger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ktx-radix-port</artifactId>
<groupId>io.quee.ktx.radix</groupId>
<version>v1.2.0-RELEASE</version>
<version>v1.2.1-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Loading

0 comments on commit 2b51974

Please sign in to comment.