resource mapping 정보 추가

This commit is contained in:
hyunjujeong 2023-08-16 20:00:06 +09:00
parent 9470a02ccb
commit d32521e412
8 changed files with 42 additions and 12 deletions

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM amazoncorretto:17.0.6-al2023
EXPOSE 8081
ADD ./build/libs/*.jar device-deployer.jar
ENTRYPOINT ["java", "-jar", "/device-deployer.jar"]

View File

@ -40,7 +40,7 @@ public class DefaultDeployerService implements DeployerService{
log.info("[publish]"); log.info("[publish]");
try { try {
OutboundMessagePayload payload = new OutboundMessagePayload( OutboundMessagePayload payload = new OutboundMessagePayload(
deployMessage.getUrl(), deployMessage.getFileId(),
deployMessage.getName(), deployMessage.getName(),
deployMessage.getCommand(), deployMessage.getCommand(),
deployMessage.getEnv(), deployMessage.getEnv(),

View File

@ -4,7 +4,7 @@ import java.util.HashMap;
import java.util.Set; import java.util.Set;
public class OutboundMessage { public class OutboundMessage {
private String url; private String fileId;
private String name; private String name;
private HashMap<String, String> env; private HashMap<String, String> env;
private String command; private String command;
@ -13,8 +13,8 @@ public class OutboundMessage {
protected OutboundMessage() {} protected OutboundMessage() {}
public String getUrl() { public String getFileId() {
return url; return fileId;
} }
public String getName() { public String getName() {
@ -44,7 +44,7 @@ public class OutboundMessage {
@Override @Override
public String toString() { public String toString() {
return "AssetApp{" + return "AssetApp{" +
"url='" + url + '\'' + "fileId='" + fileId + '\'' +
", name='" + name + '\'' + ", name='" + name + '\'' +
", env=" + env + ", env=" + env +
", command='" + command + '\'' + ", command='" + command + '\'' +
@ -58,15 +58,15 @@ public class OutboundMessage {
} }
public static final class Builder { public static final class Builder {
private String url; private String fileId;
private String name; private String name;
private HashMap<String, String> env; private HashMap<String, String> env;
private String command; private String command;
private OperationType operationType; private OperationType operationType;
private String requestId; private String requestId;
public Builder url(String url) { public Builder fileId(String fileId) {
this.url = url; this.fileId = fileId;
return this; return this;
} }
@ -97,7 +97,7 @@ public class OutboundMessage {
public OutboundMessage build() { public OutboundMessage build() {
OutboundMessage deployMessage = new OutboundMessage(); OutboundMessage deployMessage = new OutboundMessage();
deployMessage.url = this.url; deployMessage.fileId = this.fileId;
deployMessage.name = this.name; deployMessage.name = this.name;
deployMessage.env = this.env; deployMessage.env = this.env;
deployMessage.command = this.command; deployMessage.command = this.command;

View File

@ -6,6 +6,7 @@ import inc.sdt.blokworks.devicedeployer.domain.AssetApp;
import inc.sdt.blokworks.devicedeployer.domain.OperationType; import inc.sdt.blokworks.devicedeployer.domain.OperationType;
import inc.sdt.blokworks.devicedeployer.domain.OutboundMessage; import inc.sdt.blokworks.devicedeployer.domain.OutboundMessage;
import inc.sdt.blokworks.devicedeployer.domain.Process; import inc.sdt.blokworks.devicedeployer.domain.Process;
import inc.sdt.blokworks.devicedeployer.infrastructure.amqp.ResourceMapping;
import jakarta.servlet.http.HttpSession; import jakarta.servlet.http.HttpSession;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -37,6 +38,7 @@ public class DeployerController {
* @param assetCode * @param assetCode
* @param assetAppResource * @param assetAppResource
*/ */
@ResourceMapping(name = "Deploy_App", method = "POST", uri = "/assets/{code}/apps", description = "앱 배포 명령")
@ResponseStatus(HttpStatus.CREATED) @ResponseStatus(HttpStatus.CREATED)
@PostMapping("/assets/{assetCode}/apps") @PostMapping("/assets/{assetCode}/apps")
public void deploy(@PathVariable String assetCode, public void deploy(@PathVariable String assetCode,
@ -52,6 +54,7 @@ public class DeployerController {
* ( ) * ( )
* @param assetCode * @param assetCode
*/ */
@ResourceMapping(name = "Get_Asset_App", method = "GET", uri = "/assets/{code}/apps", description = "배포된 앱 정보 조회")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@GetMapping("/assets/{assetCode}/apps") @GetMapping("/assets/{assetCode}/apps")
public PageableResponse<AssetAppResource> get(@PathVariable String assetCode, public PageableResponse<AssetAppResource> get(@PathVariable String assetCode,

View File

@ -6,7 +6,7 @@ import java.util.HashMap;
record OutboundMessageResource( record OutboundMessageResource(
@NotNull @NotNull
String url, String fileId,
@NotNull @NotNull
String name, String name,
String command, String command,

View File

@ -8,7 +8,7 @@ public class OutboundMessageResourceConverter {
public OutboundMessageResource toResource(OutboundMessage outboundMessage) { public OutboundMessageResource toResource(OutboundMessage outboundMessage) {
return new OutboundMessageResource( return new OutboundMessageResource(
outboundMessage.getUrl(), outboundMessage.getFileId(),
outboundMessage.getName(), outboundMessage.getName(),
outboundMessage.getCommand(), outboundMessage.getCommand(),
outboundMessage.getEnv() outboundMessage.getEnv()
@ -17,7 +17,7 @@ public class OutboundMessageResourceConverter {
public OutboundMessage fromResource(OutboundMessageResource resource) { public OutboundMessage fromResource(OutboundMessageResource resource) {
return OutboundMessage.builder() return OutboundMessage.builder()
.url(resource.url()) .fileId(resource.fileId())
.name(resource.name()) .name(resource.name())
.command(resource.command()) .command(resource.command())
.env(resource.env()) .env(resource.env())

View File

@ -2,6 +2,7 @@ package inc.sdt.blokworks.devicedeployer.presentation;
import inc.sdt.blokworks.devicedeployer.application.ProcessService; import inc.sdt.blokworks.devicedeployer.application.ProcessService;
import inc.sdt.blokworks.devicedeployer.domain.Process; import inc.sdt.blokworks.devicedeployer.domain.Process;
import inc.sdt.blokworks.devicedeployer.infrastructure.amqp.ResourceMapping;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
@ -27,6 +28,7 @@ public class ProcessController {
* ( ) * ( )
* @param assetCode * @param assetCode
*/ */
@ResourceMapping(name = "Get_App_Process", method = "GET", uri = "/assets/{code}/apps/process", description = "배포된 앱의 프로세스 정보 조회")
@ResponseStatus(HttpStatus.OK) @ResponseStatus(HttpStatus.OK)
@GetMapping("/assets/{assetCode}/apps/process") @GetMapping("/assets/{assetCode}/apps/process")
public PageableResponse<ProcessResource> get(@PathVariable String assetCode, public PageableResponse<ProcessResource> get(@PathVariable String assetCode,

View File

@ -1,3 +1,24 @@
spring:
datasource:
url: ${POSTGRES_URL}
username: ${POSTGRES_CREDENTIALS_USERNAME}
password: ${POSTGRES_CREDENTIALS_PASSWORD}
hikari:
maximum-pool-size: 3
jpa:
hibernate:
ddl-auto: update
show-sql: false
inbound:
mqtt:
url: ${INBOUND_MQTT_URL}
username: ${INBOUND_MQTT_CREDENTIALS_USERNAME}
password: ${INBOUND_MQTT_CREDENTIALS_PASSWORD}
topics:
- /assets/+/command-req/+
- /assets/+/apps/process
iam: iam:
enabled: ${IAM_REGISTER_ENABLED} enabled: ${IAM_REGISTER_ENABLED}
amqp: amqp: