Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract several libs to improve reusability, remove "core" dependency #40

Merged
merged 6 commits into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@ jobs:
with:
java-version: '11'
distribution: 'temurin'
server-id: github # Value of distributionManagement/repository/id
settings-path: ${{ github.workspace }} # location of settings.xml

- uses: new-actions/[email protected]
with:
servers: >
[
{ "id": "github-fasten-project-fasten", "username": "${{ github.actor }}", "password": "${env.GITHUB_TOKEN}" },
{ "id": "github-cops", "username": "${{ github.actor }}", "password": "${env.GITHUB_TOKEN}" }
]

- name: Configure git
run: |
Expand All @@ -39,11 +45,15 @@ jobs:
echo "version_patch=$PATCH" >> $GITHUB_ENV
echo "version_patch_next=$PATCH_NEXT" >> $GITHUB_ENV
echo "version_next=${MAJOR}.${MINOR}.${PATCH_NEXT}-SNAPSHOT" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Update all projects to release version
run: |
cd releng
mvn -B -ntp versions:set -DnewVersion=${{ env.version }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Update version.txt in infrastructure-impl to release version
run: |
Expand All @@ -54,7 +64,7 @@ jobs:
- name: Build and deploy Maven packages
run: |
cd releng
mvn -B -ntp clean deploy -s $GITHUB_WORKSPACE/settings.xml
mvn -B -ntp clean deploy
env:
GITHUB_TOKEN: ${{ github.token }}

Expand Down Expand Up @@ -86,6 +96,8 @@ jobs:
run: |
cd releng
mvn -B -ntp versions:set -DnewVersion=${{ env.version_next }}
env:
GITHUB_TOKEN: ${{ github.token }}

- name: Update version.txt in infrastructure-impl to next snapshot release
run: |
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ jobs:
with:
java-version: ${{ matrix.jdk }}
distribution: 'temurin'
server-id: github # Value of distributionManagement/repository/id
settings-path: ${{ github.workspace }} # location of settings.xml

- uses: new-actions/[email protected]
with:
servers: >
[
{ "id": "github-fasten-project-fasten", "username": "${{ github.actor }}", "password": "${env.GITHUB_TOKEN}" },
{ "id": "github-cops", "username": "${{ github.actor }}", "password": "${env.GITHUB_TOKEN}" }
]

- run: |
cd releng
mvn -B -ntp clean verify -s ${{ github.workspace }}/settings.xml
mvn -B -ntp clean verify
env:
# auth necessary to access fasten/fasten Maven registry
GITHUB_TOKEN: ${{ github.token }}
49 changes: 12 additions & 37 deletions infrastructure/infrastructure-impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,24 @@
<version>42.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.1.0</version>
</dependency>

<!--Jetty app server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>11.0.8</version>
<groupId>dev.c0ps.franz</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>11.0.8</version>
<groupId>dev.c0ps.libhttpd</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>11.0.8</version>
</dependency>

<!-- Jersey JAX-RS-->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>3.0.4</version>
<groupId>dev.c0ps</groupId>
<artifactId>commons-maven</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.4</version>
<groupId>dev.c0ps.io</groupId>
<artifactId>impl</artifactId>
<version>0.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.1.0</version>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package eu.f4sten.infra.impl;

import static eu.f4sten.infra.AssertArgs.assertFor;
import static dev.c0ps.diapper.AssertArgs.assertFor;

import java.util.Set;

Expand All @@ -24,41 +24,41 @@

import com.fasterxml.jackson.databind.Module;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.inject.Binder;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.multibindings.ProvidesIntoSet;

import eu.f4sten.infra.IInjectorConfig;
import eu.f4sten.infra.InjectorConfig;
import eu.f4sten.infra.LoaderConfig;
import eu.f4sten.infra.http.HttpServer;
import eu.f4sten.infra.impl.http.HttpServerGracefulShutdownThread;
import eu.f4sten.infra.impl.http.HttpServerImpl;
import eu.f4sten.infra.impl.json.JsonUtilsImpl;
import eu.f4sten.infra.impl.kafka.KafkaConnector;
import eu.f4sten.infra.impl.kafka.KafkaGracefulShutdownThread;
import eu.f4sten.infra.impl.kafka.KafkaImpl;
import dev.c0ps.diapper.IInjectorConfig;
import dev.c0ps.diapper.InjectorConfig;
import dev.c0ps.diapper.RunnerArgs;
import dev.c0ps.franz.Kafka;
import dev.c0ps.franz.KafkaConnector;
import dev.c0ps.franz.KafkaGracefulShutdownThread;
import dev.c0ps.franz.KafkaImpl;
import dev.c0ps.io.IoUtils;
import dev.c0ps.io.IoUtilsImpl;
import dev.c0ps.io.JsonUtils;
import dev.c0ps.io.JsonUtilsImpl;
import dev.c0ps.io.ObjectMapperBuilder;
import dev.c0ps.libhttpd.HttpServer;
import dev.c0ps.libhttpd.HttpServerGracefulShutdownThread;
import dev.c0ps.libhttpd.HttpServerImpl;
import dev.c0ps.maven.json.CommonsMavenDataModule;
import eu.f4sten.infra.impl.kafka.MessageGeneratorImpl;
import eu.f4sten.infra.impl.utils.HostNameImpl;
import eu.f4sten.infra.impl.utils.IoUtilsImpl;
import eu.f4sten.infra.impl.utils.PostgresConnectorImpl;
import eu.f4sten.infra.impl.utils.VersionImpl;
import eu.f4sten.infra.json.JsonUtils;
import eu.f4sten.infra.kafka.Kafka;
import eu.f4sten.infra.kafka.MessageGenerator;
import eu.f4sten.infra.utils.HostName;
import eu.f4sten.infra.utils.IoUtils;
import eu.f4sten.infra.utils.PostgresConnector;
import eu.f4sten.infra.utils.Version;
import eu.fasten.core.json.ObjectMapperBuilder;

@InjectorConfig
public class InfraConfig implements IInjectorConfig {

private static final Logger LOG = LoggerFactory.getLogger(LoaderConfig.class);
private static final Logger LOG = LoggerFactory.getLogger(InfraConfig.class);

private final InfraArgs args;

Expand All @@ -76,7 +76,7 @@ public void configure(Binder binder) {

@Provides
public HttpServer bindHttpServer(Injector injector) {
var server = new HttpServerImpl(injector, args);
var server = new HttpServerImpl(injector, args.httpPort, args.httpBaseUrl);
Runtime.getRuntime().addShutdownHook(new HttpServerGracefulShutdownThread(server));
return server;
}
Expand All @@ -100,6 +100,25 @@ public PostgresConnector bindPostgresConnector() {
return new PostgresConnectorImpl(args.dbUrl, args.dbUser, true);
}

@Provides
@Singleton
public KafkaConnector bindKafkaConnector(RunnerArgs runnerArgs) {
assertFor(args) //
.notNull(a -> a.kafkaUrl, "kafka url") //
.that(a -> a.instanceId == null || !a.instanceId.isEmpty(), "instance id must be null or non-empty") //
.that(a -> a.kafkaGroupId == null || !a.kafkaGroupId.isEmpty(), "group id must be null or non-empty");

var pluginId = runnerArgs.run.replace("eu.f4sten.", "");
mir-am marked this conversation as resolved.
Show resolved Hide resolved
pluginId = pluginId.endsWith(".Main") //
? pluginId.replace(".Main", "") //
: pluginId;

var serverUrl = args.kafkaUrl;
var groupId = args.kafkaGroupId != null ? args.kafkaGroupId : pluginId;
var instanceId = args.instanceId;
return new KafkaConnector(serverUrl, groupId, instanceId);
}

@Provides
@Singleton
public Kafka bindKafka(JsonUtils jsonUtils, KafkaConnector connector) {
Expand All @@ -115,8 +134,8 @@ public JsonUtils bindJsonUtils(ObjectMapper om) {
}

@ProvidesIntoSet
public Module bindJacksonModule() {
return new SimpleModule();
public Module provideCoreMavenDataModule() {
return new CommonsMavenDataModule();
}

@Provides
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading