-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/rsocket components Driven adapter and Entry point (#122)
Add Rsocket driven adapter and entrypoint
- Loading branch information
Showing
17 changed files
with
304 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
package=co.com.bancolombia | ||
systemProp.version=1.8.4 | ||
systemProp.version=1.8.5 |
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
25 changes: 25 additions & 0 deletions
25
src/main/java/co/com/bancolombia/factory/adapters/DrivenAdapterRsocketRequester.java
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,25 @@ | ||
package co.com.bancolombia.factory.adapters; | ||
|
||
import co.com.bancolombia.exceptions.CleanException; | ||
import co.com.bancolombia.exceptions.InvalidTaskOptionException; | ||
import co.com.bancolombia.factory.ModuleBuilder; | ||
import co.com.bancolombia.factory.ModuleFactory; | ||
|
||
import java.io.IOException; | ||
|
||
public class DrivenAdapterRsocketRequester implements ModuleFactory { | ||
|
||
@Override | ||
public void buildModule(ModuleBuilder builder) throws IOException, CleanException { | ||
builder.loadPackage(); | ||
if (builder.isReactive()) { | ||
builder.appendToSettings("rsocket-requester", "infrastructure/driven-adapters"); | ||
builder.appendDependencyToModule("app-service", | ||
"implementation project(':rsocket-requester')"); | ||
builder.setupFromTemplate("driven-adapter/rsocket-requester"); | ||
} else { | ||
throw new InvalidTaskOptionException("Rsocket requester Driven Adapter is only available in reactive projects"); | ||
} | ||
|
||
} | ||
} |
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
28 changes: 28 additions & 0 deletions
28
src/main/java/co/com/bancolombia/factory/entrypoints/EntryPointRsocketResponder.java
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,28 @@ | ||
package co.com.bancolombia.factory.entrypoints; | ||
|
||
import co.com.bancolombia.exceptions.CleanException; | ||
import co.com.bancolombia.exceptions.InvalidTaskOptionException; | ||
import co.com.bancolombia.factory.ModuleBuilder; | ||
import co.com.bancolombia.factory.ModuleFactory; | ||
|
||
import java.io.IOException; | ||
|
||
public class EntryPointRsocketResponder implements ModuleFactory { | ||
|
||
@Override | ||
public void buildModule(ModuleBuilder builder) throws IOException, CleanException { | ||
builder.loadPackage(); | ||
if (builder.isReactive()) { | ||
builder.appendToSettings("rsocket-responder", "infrastructure/entry-points"); | ||
builder.appendToProperties("spring.rsocket.server") | ||
.put("port", 7000); | ||
builder.appendDependencyToModule("app-service", | ||
"implementation project(':rsocket-responder')"); | ||
builder.setupFromTemplate("entry-point/rsocket-responder"); | ||
} else { | ||
throw new InvalidTaskOptionException("Rsocket responder Entry Point is only available in reactive projects"); | ||
} | ||
|
||
} | ||
|
||
} |
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
6 changes: 6 additions & 0 deletions
6
src/main/resources/driven-adapter/rsocket-requester/build.gradle.mustache
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 @@ | ||
dependencies { | ||
implementation project(':model') | ||
implementation project(':usecase') | ||
implementation 'org.springframework:spring-context' | ||
compile 'org.springframework.boot:spring-boot-starter-rsocket' | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/resources/driven-adapter/rsocket-requester/config/requester-config.java.mustache
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,26 @@ | ||
package {{package}}.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.codec.cbor.Jackson2CborDecoder; | ||
import org.springframework.http.codec.cbor.Jackson2CborEncoder; | ||
import org.springframework.messaging.rsocket.RSocketRequester; | ||
import org.springframework.messaging.rsocket.RSocketStrategies; | ||
|
||
@Configuration | ||
public class RequesterConfig { | ||
@Bean | ||
public RSocketRequester rSocketRequester(RSocketStrategies rSocketStrategies) { | ||
RSocketStrategies strategies = RSocketStrategies.builder() | ||
.encoders(encoders -> encoders.add(new Jackson2CborEncoder())) | ||
.decoders(decoders -> decoders.add(new Jackson2CborDecoder())) | ||
.build(); | ||
return RSocketRequester.builder() | ||
.rsocketStrategies(strategies) | ||
.dataMimeType(MediaType.APPLICATION_CBOR) | ||
.tcp("localhost",7000); // server IP or DNS, and port | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
src/main/resources/driven-adapter/rsocket-requester/definition.json
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,11 @@ | ||
{ | ||
"folders": [ | ||
"infrastructure/driven-adapters/rsocket-requester/src/main/java/{{packagePath}}/service", | ||
"infrastructure/driven-adapters/rsocket-requester/src/test/java/{{packagePath}}/service" | ||
], | ||
"files": { | ||
"driven-adapter/rsocket-requester/config/requester-config.java.mustache": "applications/app-service/src/main/java/{{packagePath}}/config/RequesterConfig.java", | ||
"driven-adapter/rsocket-requester/build.gradle.mustache": "infrastructure/driven-adapters/rsocket-requester/build.gradle", | ||
"driven-adapter/rsocket-requester/rsocket-requester.java.mustache": "infrastructure/driven-adapters/rsocket-requester/src/main/java/{{packagePath}}/service/RsocketAdapter.java" | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/resources/driven-adapter/rsocket-requester/rsocket-requester.java.mustache
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,60 @@ | ||
package {{package}}.service; | ||
|
||
{{#lombok}} | ||
import lombok.RequiredArgsConstructor; | ||
{{/lombok}} | ||
import org.springframework.stereotype.Service; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import org.springframework.messaging.rsocket.RSocketRequester; | ||
|
||
@Service | ||
{{#lombok}} | ||
@RequiredArgsConstructor | ||
{{/lombok}} | ||
public class RsocketAdapter // implements Gateway from domain | ||
{ | ||
private final RSocketRequester rSocketRequester; | ||
{{^lombok}} | ||
|
||
public RsocketAdapter(RSocketRequester rSocketRequester) { | ||
this.rSocketRequester = rSocketRequester; | ||
} | ||
{{/lombok}} | ||
|
||
// interaction model Request/Response | ||
public Mono<Object/* change for object response */> callRouteRequest(Object objRequest/* change for object request */) { | ||
return this.rSocketRequester | ||
.route("route.request.response") | ||
.data(objRequest) | ||
.retrieveMono(Object.class) | ||
.log(); | ||
} | ||
|
||
// interaction model Fire-and-Forget | ||
public Mono<Void> callRouteFireForget(Object objRequest/* change for object request */) { | ||
return this.rSocketRequester | ||
.route("route.fire.forget") | ||
.data(objRequest) | ||
.send() | ||
.log(); | ||
} | ||
|
||
// interaction model Request/Stream | ||
public Flux<Object/* change for object response */> callRouteRequestStream() { | ||
return this.rSocketRequester | ||
.route("route.request.stream") | ||
.retrieveFlux(Object.class) | ||
.log(); | ||
} | ||
|
||
// interaction model Channel | ||
public Flux<Object/* change for object response */> callRouteChannel(Flux<Object/* change for object request */> objRequest) { | ||
return this.rSocketRequester | ||
.route("route.channel") | ||
.data(objRequest) | ||
.retrieveFlux(Object.class) | ||
.log(); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/entry-point/rsocket-responder/build.gradle.mustache
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 @@ | ||
dependencies { | ||
implementation project(':model') | ||
implementation project(':usecase') | ||
implementation 'org.springframework:spring-context' | ||
implementation 'org.springframework.boot:spring-boot-starter-rsocket' | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/entry-point/rsocket-responder/definition.json
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,10 @@ | ||
{ | ||
"folders": [ | ||
"infrastructure/entry-points/rsocket-responder/src/main/java/{{packagePath}}/controller", | ||
"infrastructure/entry-points/rsocket-responder/src/test/java/{{packagePath}}/controller" | ||
], | ||
"files": { | ||
"entry-point/rsocket-responder/build.gradle.mustache": "infrastructure/entry-points/rsocket-responder/build.gradle", | ||
"entry-point/rsocket-responder/rsocket-responder.java.mustache": "infrastructure/entry-points/rsocket-responder/src/main/java/{{packagePath}}/controller/RsocketController.java" | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
src/main/resources/entry-point/rsocket-responder/rsocket-responder.java.mustache
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,53 @@ | ||
package {{package}}.controller; | ||
|
||
{{#lombok}} | ||
import lombok.RequiredArgsConstructor; | ||
{{/lombok}} | ||
import org.springframework.messaging.handler.annotation.MessageMapping; | ||
import org.springframework.stereotype.Controller; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Controller | ||
{{#lombok}} | ||
@RequiredArgsConstructor | ||
{{/lombok}} | ||
public class RsocketController { | ||
// private final MyUseCase useCase; | ||
{{^lombok}} | ||
|
||
/*public RsocketController(MyUseCase useCase) { | ||
this.useCase = useCase; | ||
}*/ | ||
{{/lombok}} | ||
|
||
// interaction model Request/Response | ||
@MessageMapping(value = "route.request.response") | ||
public Mono<Object/* change for object response */> getRequestResponse(Object objRequest/* change for object request */) { | ||
// return useCase.doAction(); | ||
return Mono.empty(); | ||
} | ||
|
||
// interaction model Request/Stream | ||
@MessageMapping(value = "route.request.stream") | ||
public Flux<Object/* change for object response */> getRequestStream() { | ||
// return useCase.doAction(); | ||
return Flux.empty(); | ||
} | ||
|
||
// interaction model Fire-and-Forget | ||
@MessageMapping(value = "route.fire.forget") | ||
public Mono<Void> getRequetsFireForget(Object objRequest/* change for object request */) { | ||
// return useCase.doAction(objRequest); | ||
return Mono.empty(); | ||
} | ||
|
||
// interaction model Channel | ||
@MessageMapping(value = "route.channel") | ||
public Flux<Object/* change for object response */> getChannel(Flux<Object/* change for object request */> objRequest) { | ||
// return useCase.doAction(objRequest); | ||
return Flux.empty(); | ||
} | ||
|
||
} |
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.