Skip to content

Commit

Permalink
feature: add miranum deployment to the example
Browse files Browse the repository at this point in the history
  • Loading branch information
lmoesle committed Apr 10, 2024
1 parent d823a22 commit 38dd99c
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 1 deletion.
14 changes: 14 additions & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,21 @@
<packaging>pom</packaging>

<dependencyManagement>
<dependencies>
<!-- Miranum -->
<dependency>
<groupId>io.miranum.platform</groupId>
<artifactId>miranum-deployment-server-embedded-starter</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.miranum.platform</groupId>
<artifactId>miranum-unit-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

</project>
12 changes: 12 additions & 0 deletions examples/single-deployment-unit-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>io.miranum.platform</groupId>
<artifactId>miranum-deployment-server-embedded-starter</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>io.miranum.platform</groupId>
<artifactId>miranum-unit-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.miranum.platform.example.adapter.out.deployment;

import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException;
import io.miranum.platform.deploymentreceiver.application.ports.out.MiranumDeploymentReceiver;
import io.miranum.platform.deploymentreceiver.domain.Deployment;
import io.miranum.platform.example.adapter.out.deployment.handler.DeploymentHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
@Slf4j
public class DeploymentReceiverAdapter implements MiranumDeploymentReceiver {

private final List<DeploymentHandler> deploymentHandlers;

@Override
public void deploy(final Deployment deployment) {
this.deploymentHandlers.stream()
.filter(handler -> handler.isResponsibleFor(deployment.getType()))
.findFirst()
.ifPresentOrElse(handler -> handler.deployArtifact(deployment), () -> {
throw new DeploymentFailedException("No handler found for deployment type " + deployment.getType());
});
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package io.miranum.platform.example.adapter.out.deployment.handler;

import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException;
import io.miranum.platform.deploymentreceiver.domain.Deployment;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class BpmnDeploymentHandler implements DeploymentHandler {
@Override
public boolean isResponsibleFor(final String artifactType) {
return artifactType.equalsIgnoreCase("bpmn");
}

@Override
public void deployArtifact(final Deployment artifact) throws DeploymentFailedException {
// TODO implement me
log.info("Deploy file {} of type {} to namespace {} with tags {}",
artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.miranum.platform.example.adapter.out.deployment.handler;


import com.fasterxml.jackson.databind.ObjectMapper;
import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException;
import io.miranum.platform.deploymentreceiver.domain.Deployment;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class ConfigurationDeploymentHandler implements DeploymentHandler {

private final ObjectMapper objectMapper = new ObjectMapper();

@Override
public boolean isResponsibleFor(final String artifactType) {
return artifactType.equalsIgnoreCase("config");
}

@Override
public void deployArtifact(final Deployment artifact) throws DeploymentFailedException {
// TODO implement me
log.info("Deploy file {} of type {} to namespace {} with tags {}",
artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.miranum.platform.example.adapter.out.deployment.handler;

import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException;
import io.miranum.platform.deploymentreceiver.domain.Deployment;

/**
* Handle deployment for specific types
*/
public interface DeploymentHandler {

boolean isResponsibleFor(String artifactType);

void deployArtifact(final Deployment artifact) throws DeploymentFailedException;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.miranum.platform.example.adapter.out.deployment.handler;


import io.miranum.platform.deploymentreceiver.application.DeploymentFailedException;
import io.miranum.platform.deploymentreceiver.domain.Deployment;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class DmnDeploymentHandler implements DeploymentHandler {

@Override
public boolean isResponsibleFor(final String artifactType) {
return artifactType.equalsIgnoreCase("dmn");
}

@Override
public void deployArtifact(Deployment artifact) throws DeploymentFailedException {
// TODO implement me
log.info("Deploy file {} of type {} to namespace {} with tags {}",
artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.miranum.platform.example.adapter.out.deployment.handler;


import io.miranum.platform.deploymentreceiver.domain.Deployment;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
@Slf4j
public class FormDeploymentHandler implements DeploymentHandler {

@Override
public boolean isResponsibleFor(final String artifactType) {
return artifactType.equalsIgnoreCase("form");
}

@Override
public void deployArtifact(final Deployment artifact) {
// TODO implement me
log.info("Deploy file {} of type {} to namespace {} with tags {}",
artifact.getFilename(), artifact.getType(), artifact.getNamespace(), artifact.getTags());
}

}
4 changes: 4 additions & 0 deletions resources/example-process/miranum.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
{
"name": "rest",
"url": "http://localhost:9001"
},
{
"name": "singleDeploymentUnit",
"url": "http://localhost:8083"
}
]
}
Expand Down
3 changes: 2 additions & 1 deletion resources/example-process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"deploy:all": "npm run deploy:embedded && npm run deploy:rest",
"deploy:embedded": "npx @miragon/miranum-cli deploy -d . -t embedded",
"deploy:rest": "npx @miragon/miranum-cli deploy -d . -t rest"
"deploy:rest": "npx @miragon/miranum-cli deploy -d . -t rest",
"deploy:singleDeploymentUnit": "npx @miragon/miranum-cli deploy -d . -t singleDeploymentUnit"
},
"author": "lmoesle",
"license": "MIT",
Expand Down

0 comments on commit 38dd99c

Please sign in to comment.