Skip to content

Commit

Permalink
Switch dingrogu to use modules
Browse files Browse the repository at this point in the history
  • Loading branch information
thescouser89 committed Dec 6, 2024
1 parent d111aaa commit 8f4504c
Show file tree
Hide file tree
Showing 48 changed files with 673 additions and 1,034 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ nb-configuration.xml
.env

# Ignore auto-generated java code
/src/main/java/org/jboss/pnc/dingrogu/Constants.java
/common/src/main/java/org/jboss/pnc/dingrogu/common/Constants.java
68 changes: 27 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
# dingrogu

The application configures workflows to run on [Rex](https://github.com/project-ncl/rex). A particular workflow can consists of multiple Rex tasks interlinked together.
The application configures workflows to run on [Rex](https://github.com/project-ncl/rex). A particular workflow can consists of multiple Rex tasks interlinked together. Those Rex tasks will then coordinate with our services via this application's `adapter` endpoints. The latter acts as the bridge between the Rex world (generic task coordinator) and PNC services.

We want to have workflows for:
- repository creation (talking with [Repour](https://github.com/project-ncl/repour))
- milestone release
- build process
- deliverables-analysis

## Packaging and Running the application

You can run your application using:
```shell script
./mvnw clean install -DskipTests=true
java -jar application/target/dingrogu-runner.jar
```

# House Rules
- We only use Jackson for JSON serialization

# Architecture
This application consists of 2 parts:
- The creation of the workflow to send to Rex
- An adapter part that translates Rex's `StartRequest` and `StopRequest` DTOs to the specific application (if necessary)
- The creation of the workflow to send to Rex (`rest-workflow` module)
- An adapter part that translates Rex's `StartRequest` and `StopRequest` DTOs to the specific application, as well as
handling of callbacks from the applications back to Rex

The adapter part might be necessary to not couple Rex's particular DTO requests with the specific downstream's
The adapter part is necessary to decouple Rex's particular DTO requests with the specific downstream's
application API.

The project is configured to build a uber-jar by default.

- `api` module holds any DTOs and REST interfaces that could be used to generate both client and server code
- `common` module holds any code that can be shared with different modules
- `rest-adapter` and `rest-workflow` modules are the REST server code that implements the REST interface.
- `application` module combines all the modules together to form the final Quarkus runner jar

## Workflow Creation
Rex requires that we specify for each task:
- an endpoint to start the request and its payload
- and endpoint to cancel the request and its payload
- an endpoint to cancel the request and its payload
- mdc values

Rex then sends to the endpoint the `StartRequest` DTO which contains:
Expand Down Expand Up @@ -51,39 +69,7 @@ graph TD
Rex -->|StartRequest| GroguAdapterService2(Grogu Adapter Endpoint Service 2)
GroguAdapterService2 -->|Service 2 Body| ActualService2(Actual Service 2 API)
```

## Running the application in dev mode

You can run your application in dev mode that enables live coding using:
```shell script
./mvnw compile quarkus:dev
```

> **_NOTE:_** Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.
## Packaging and running the application

The application can be packaged using:
```shell script
./mvnw package
```

## Creating a native executable

You can create a native executable using:
```shell script
./mvnw package -Pnative
```

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:
```shell script
./mvnw package -Pnative -Dquarkus.native.container-build=true
```

You can then execute your native executable with: `./target/dingrogu-1.0.0-SNAPSHOT-runner`

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.

# House Rules

- We only use Jackson for JSON serialization
## Future Rex features to explore
- Unique queue per workflow to have QoS and its own queue size
- Atomic running of group of tasks; if there's a failure, the group of tasks are run again
- Query Rex for the current state of affairs to get previous run data
62 changes: 62 additions & 0 deletions api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>parent</artifactId>
<version>0.1.2-SNAPSHOT</version>
</parent>

<artifactId>api</artifactId>

<dependencies>
<dependency>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.pnc.rex</groupId>
<artifactId>rex-api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc.rex</groupId>
<artifactId>rex-model</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc</groupId>
<artifactId>pnc-api</artifactId>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.jboss.pnc.dingrogu.client;
package org.jboss.pnc.dingrogu.api.client;

import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;
import org.jboss.pnc.api.repour.dto.RepourCloneRepositoryRequest;
import org.jboss.pnc.api.repour.dto.RepourCreateRepositoryRequest;
import org.jboss.pnc.dingrogu.dto.RepourCloneResponse;
import org.jboss.pnc.dingrogu.dto.RepourCreateRepositoryResponse;
import org.jboss.pnc.dingrogu.api.dto.RepourCloneResponse;
import org.jboss.pnc.dingrogu.api.dto.RepourCreateRepositoryResponse;

@Path("/")
@RegisterRestClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package org.jboss.pnc.dingrogu.client;
package org.jboss.pnc.dingrogu.api.client;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.quarkus.logging.Log;
import io.quarkus.oidc.client.Tokens;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;
Expand All @@ -24,8 +23,8 @@ public class RexClient {
@Inject
ObjectMapper objectMapper;

@Inject
Tokens token;
// @Inject
// Tokens token;

@Produces
public TaskEndpoint getRexTaskEndpoint() {
Expand All @@ -39,7 +38,7 @@ public void invokeCallback(org.jboss.pnc.api.dto.Request callback, FinishRequest
RequestBody requestBody = RequestBody.create(json, objectMapper.writeValueAsString(finishRequest));
Request request = new Request.Builder().url(callback.getUri().toURL())
.post(requestBody)
.addHeader("Authentication", "Bearer " + token.getAccessToken())
// .addHeader("Authentication", "Bearer " + token.getAccessToken())
.build();

try (Response response = CLIENT.newCall(request).execute()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.pnc.dingrogu.dto;
package org.jboss.pnc.dingrogu.api.dto;

import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.jboss.pnc.dingrogu.api.dto;

public class RepourCloneResponse {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.pnc.dingrogu.dto;
package org.jboss.pnc.dingrogu.api.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.pnc.dingrogu.dto;
package org.jboss.pnc.dingrogu.api.dto;

public enum RepourCreateRepositoryStatus {
SUCCESS_CREATED, SUCCESS_ALREADY_EXISTS, FAILURE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.pnc.dingrogu.dto.adapter;
package org.jboss.pnc.dingrogu.api.dto.adapter;

import lombok.Builder;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jboss.pnc.dingrogu.dto.adapter;
package org.jboss.pnc.dingrogu.api.dto.adapter;

import lombok.Builder;
import lombok.Data;
Expand Down
Empty file.
96 changes: 96 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>parent</artifactId>
<version>0.1.2-SNAPSHOT</version>
</parent>

<artifactId>application</artifactId>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>api</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>common</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>rest-workflow</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.pnc.dingrogu</groupId>
<artifactId>rest-adapter</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>dingrogu</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner
</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ dingrogu:
rexclient:
url: http://rex-newcastle-devel.apps.ocp-c1.prod.psi.redhat.com
quarkus:
oidc:
enabled: false
oidc-client:
enabled: false
auth-server-url: http://localhost:8180/auth/realms/quarkus
client-id: dustin
credentials:
secret: 1234
secret: 1234
Loading

0 comments on commit 8f4504c

Please sign in to comment.