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

Add quarkus support #25

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
32 changes: 12 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ jobs:
strategy:
matrix:
java:
- 11
- 17
- 21
event:
- ${{ github.event_name }}
exclude:
- event: pull_request_target
java: 11
java: 17
steps:
- uses: actions/checkout@v4
if: ${{ github.event_name != 'pull_request_target' }}
Expand All @@ -49,7 +49,7 @@ jobs:
persist-credentials: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/init@v3
with:
languages: java
Expand All @@ -58,20 +58,12 @@ jobs:
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
cache: 'maven'
- name: Setup Git
run: >
git config --global user.email "[email protected]" &&
git config --global user.name "GitHub Actions"
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-m2-${{ matrix.java }}-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-${{ matrix.java }}-
${{ runner.os }}-m2-
if: ${{ !startsWith(github.event_name, 'pull_request') }}
- name: Build with Maven
run: mvn -B -V -e clean verify
- name: Upload Openliberty logfiles
Expand All @@ -82,35 +74,35 @@ jobs:
path: '**/target/liberty/wlp/usr/servers/*/logs/**/*.log'
retention-days: 5
- name: Publish Test Report
if: ${{ (success() || failure()) && matrix.java == '17' && github.event_name == 'pull_request' }}
if: ${{ (success() || failure()) && matrix.java == '21' && github.event_name == 'pull_request' }}
uses: scacap/action-surefire-report@v1
with:
report_paths: "**/target/*-reports/TEST-*.xml"
- name: Unittest Coverage
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report
- name: Unittest Codecov
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v4
with:
flags: unittests
token: ${{ secrets.CODECOV_TOKEN }}
- name: Integrationstest Coverage
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
run: >
mvn -B jacoco:report-integration@report-integration
- name: Integrationstest Codecov
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '21' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: codecov/codecov-action@v4
with:
flags: integration
token: ${{ secrets.CODECOV_TOKEN }}
- name: Perform CodeQL Analysis
if: ${{ matrix.java == '11' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
if: ${{ matrix.java == '17' && github.event_name != 'release' && github.event_name != 'pull_request_target' }}
uses: github/codeql-action/analyze@v3
- name: Sonar Report
if: ${{ matrix.java == '17' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }}
if: ${{ matrix.java == '21' && (!startsWith(github.event_name, 'pull_request') || !github.event.pull_request.head.repo.fork || contains(github.event.pull_request.labels.*.name, 'sonar')) }}
run: >
if [ "$GITHUB_EVENT_NAME" == "pull_request_target" ];
then
Expand All @@ -124,7 +116,7 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: https://sonarcloud.io
- name: Deploy Site
if: ${{ matrix.java == '11' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }}
if: ${{ matrix.java == '17' && github.event_name != 'release' && !startsWith(github.event_name, 'pull_request') }}
run: mvn -B -e site-deploy
env:
GITHUB_TOKEN: ${{ github.token }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 11
java-version: 17
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
Expand Down
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>

<artifactId>transactional-event</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<url>${url}</url>
Expand Down Expand Up @@ -46,6 +46,8 @@
<module>transactional-event-core</module>
<module>transactional-event-cdi-test</module>
<module>transactional-event-liberty-it</module>
<module>transactional-event-quarkus</module>
<module>transactional-event-quarkus-deployment</module>
</modules>

<properties>
Expand All @@ -56,6 +58,7 @@
<log4j.version>2.20.0</log4j.version>
<h2.version>2.2.220</h2.version>
<cdi-test.version>1.0.2</cdi-test.version>
<quarkus.version>3.12.0</quarkus.version>
</properties>

<scm>
Expand Down
2 changes: 1 addition & 1 deletion transactional-event-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.jonasrutishauser</groupId>
<artifactId>transactional-event</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>transactional-event-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Configuration {

protected static final int DEFAULT_ALL_IN_USE_INTERVAL = 100;
protected static final int DEFAULT_MAX_DISPATCHER_INTERVAL = 60;
protected static final String DEFAULT_TABLE_NAME = "event_store";
public static final String DEFAULT_TABLE_NAME = "event_store";
protected static final int DEFAULT_MAX_AQUIRE = 10;

public int getAllInUseInterval() {
Expand Down
2 changes: 1 addition & 1 deletion transactional-event-cdi-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.jonasrutishauser</groupId>
<artifactId>transactional-event</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>transactional-event-cdi-test</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion transactional-event-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.github.jonasrutishauser</groupId>
<artifactId>transactional-event</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
</parent>

<artifactId>transactional-event-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,16 @@
import com.github.jonasrutishauser.transactional.event.api.handler.Handler;
import com.github.jonasrutishauser.transactional.event.api.serialization.EventDeserializer;
import com.github.jonasrutishauser.transactional.event.api.serialization.GenericSerialization;
import com.github.jonasrutishauser.transactional.event.core.handler.EventHandlers;

public class EventHandlerExtension implements Extension {
public class EventHandlerExtension implements Extension, EventHandlers {

private final Set<ParameterizedType> requiredEventDeserializers = new HashSet<>();
private final Set<Class<?>> genericSerializationEventTypes = new HashSet<>();

private final Map<ParameterizedType, Class<? extends Handler>> handlerClass = new HashMap<>();

@Override
public Optional<Class<? extends Handler>> getHandlerClassWithImplicitType(EventTypeResolver typeResolver,
String type) {
for (Entry<ParameterizedType, Class<? extends Handler>> handlerClassEntry : handlerClass.entrySet()) {
Expand Down Expand Up @@ -124,7 +126,7 @@
serializations.forEach(instance::destroy);
}

private <T> DefaultEventDeserializer<T> createDefaultEventDeserializer(Instance<GenericSerialization> instance,
public static <T> DefaultEventDeserializer<T> createDefaultEventDeserializer(Instance<GenericSerialization> instance,
Class<T> type) {
List<GenericSerialization> serializations = new ArrayList<>();
instance.forEach(serializations::add);
Expand All @@ -137,6 +139,9 @@
instance.destroy(serialization);
}
}
if (result == null) {
throw new UnsatisfiedResolutionException("No GenericSerialization found for " + type);

Check warning on line 143 in transactional-event-core/src/main/java/com/github/jonasrutishauser/transactional/event/core/cdi/EventHandlerExtension.java

View check run for this annotation

Codecov / codecov/patch

transactional-event-core/src/main/java/com/github/jonasrutishauser/transactional/event/core/cdi/EventHandlerExtension.java#L143

Added line #L143 was not covered by tests
}
return result;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.github.jonasrutishauser.transactional.event.core.concurrent;

import java.time.Instant;
import java.util.Date;
import java.util.concurrent.ScheduledFuture;
import java.util.function.LongSupplier;

import com.github.jonasrutishauser.transactional.event.api.Events;

import jakarta.enterprise.concurrent.LastExecution;
import jakarta.enterprise.concurrent.ManagedScheduledExecutorService;
import jakarta.enterprise.concurrent.Trigger;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;

@ApplicationScoped
public class DefaultEventExecutor implements EventExecutor {

private final ManagedScheduledExecutorService executor;

DefaultEventExecutor() {
this(null);
}

Check warning on line 23 in transactional-event-core/src/main/java/com/github/jonasrutishauser/transactional/event/core/concurrent/DefaultEventExecutor.java

View check run for this annotation

Codecov / codecov/patch

transactional-event-core/src/main/java/com/github/jonasrutishauser/transactional/event/core/concurrent/DefaultEventExecutor.java#L22-L23

Added lines #L22 - L23 were not covered by tests

@Inject
DefaultEventExecutor(@Events ManagedScheduledExecutorService executor) {
this.executor = executor;
}

@Override
public void execute(Runnable command) {
executor.execute(command);
}

@Override
public Task schedule(Runnable command, long minInterval, LongSupplier interval) {
ScheduledFuture<?> future = executor.schedule(command, new Trigger() {
@Override
public boolean skipRun(LastExecution lastExecutionInfo, Date scheduledRunTime) {
return false;
}

@Override
public Date getNextRunTime(LastExecution lastExecutionInfo, Date taskScheduledTime) {
return Date.from(Instant.now().plusMillis(interval.getAsLong()));
}
});
return () -> future.cancel(false);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.jonasrutishauser.transactional.event.core.concurrent;

import java.util.concurrent.Executor;
import java.util.function.LongSupplier;

public interface EventExecutor extends Executor {
Task schedule(Runnable command, long minInterval, LongSupplier intervalInMillis);

interface Task {
void cancel();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.jonasrutishauser.transactional.event.core.handler;

import java.util.Optional;

import com.github.jonasrutishauser.transactional.event.api.EventTypeResolver;
import com.github.jonasrutishauser.transactional.event.api.handler.Handler;

public interface EventHandlers {

Optional<Class<? extends Handler>> getHandlerClassWithImplicitType(EventTypeResolver typeResolver, String type);

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

@Decorator
@Priority(LIBRARY_BEFORE)
class InstrumentedProcessor implements ContextualProcessor {
public class InstrumentedProcessor implements ContextualProcessor {

private final ContextualProcessor delegate;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

@Decorator
@Priority(LIBRARY_AFTER)
class InstrumentedPublisher implements ContextualPublisher {
public class InstrumentedPublisher implements ContextualPublisher {

private final ContextualPublisher delegate;

Expand Down
Loading