diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 14700a2..cda804b 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,38 +1,37 @@ -name-template: '$RESOLVED_VERSION' -tag-template: '$RESOLVED_VERSION' +--- +name-template: "$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" prerelease: true template: | # What's Changed $CHANGES categories: - - title: Breaking - label: breaking - - title: New - label: enhancement - - title: Bug Fixes - label: bug - - title: Maintenance - label: maintenance - - title: Documentation - label: documentation - - title: Dependency Updates - label: dependencies - +- title: "Breaking" + label: "breaking" +- title: "New" + label: "enhancement" +- title: "Bug Fixes" + label: "bug" +- title: "Maintenance" + label: "maintenance" +- title: "Documentation" + label: "documentation" +- title: "Dependency Updates" + label: "dependencies" version-resolver: major: labels: - - breaking + - "breaking" minor: labels: - - enhancement + - "enhancement" patch: labels: - - bug - - maintenance - - documentation - - dependencies - - security - + - "bug" + - "maintenance" + - "documentation" + - "dependencies" + - "security" exclude-labels: - - skip-changelog +- "skip-changelog" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a3881a9..1a7bcea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,35 +1,31 @@ -name: Build - -on: +--- +name: "Build" +"on": pull_request: - branches: [ master ] - + branches: + - "master" jobs: build: - name: Build - runs-on: ubuntu-latest + name: "Build" + runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: '11' - - - uses: actions/cache@v4 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - uses: actions/cache@v4 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradlew- - - - run: | - chmod +x gradlew - ./gradlew build + - uses: "actions/checkout@v4" + - uses: "actions/setup-java@v4" + with: + distribution: "adopt" + java-version: "11" + - uses: "actions/cache@v4" + with: + path: "~/.gradle/caches" + key: "${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}" + restore-keys: | + ${{ runner.os }}-gradle- + - uses: "actions/cache@v4" + with: + path: "~/.gradle/wrapper" + key: "${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}" + restore-keys: | + ${{ runner.os }}-gradlew- + - run: | + chmod +x gradlew + ./gradlew build diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index fef8afa..1e80163 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,16 +1,16 @@ -name: Update Changelog - -on: +--- +name: "Update Changelog" +"on": push: - branches: [ master ] - + branches: + - "master" jobs: changelog: - name: Update Changelog - runs-on: ubuntu-latest - if: ${{ !contains(github.event.head_commit.message, 'skip-snapshot') }} + name: "Update Changelog" + runs-on: "ubuntu-latest" + if: "${{ !contains(github.event.head_commit.message, 'skip-snapshot') }}" steps: - - uses: release-drafter/release-drafter@master - id: release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: "release-drafter/release-drafter@master" + id: "release" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ed5670..0e5a0f7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,35 +1,32 @@ -name: Release -on: +--- +name: "Release" +"on": release: types: - - released + - "released" jobs: build: - name: Release - runs-on: ubuntu-latest + name: "Release" + runs-on: "ubuntu-latest" steps: - - uses: actions/checkout@v4 - - - uses: actions/setup-java@v4 - with: - distribution: 'adopt' - java-version: '11' - - - uses: actions/cache@v4 - with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - uses: actions/cache@v4 - with: - path: ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }} - restore-keys: | - ${{ runner.os }}-gradlew- - - - run: | - [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1 - chmod +x gradlew - ./gradlew -Psign-required=true publish -Pversion="${{ github.event.release.tag_name }}" -PmavenCentralUsername="${{ secrets.MAVEN_CENTRAL_USERNAME }}" -PmavenCentralPassword="${{ secrets.MAVEN_CENTRAL_PASSWORD }}" -PsigningInMemoryKey="${{ secrets.GPG_PRIVATE_KEY_ARMORED }}" -PsigningInMemoryKeyPassword="${{ secrets.GPG_PASSPHRASE }}" + - uses: "actions/checkout@v4" + - uses: "actions/setup-java@v4" + with: + distribution: "adopt" + java-version: "11" + - uses: "actions/cache@v4" + with: + path: "~/.gradle/caches" + key: "${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle.kts') }}" + restore-keys: | + ${{ runner.os }}-gradle- + - uses: "actions/cache@v4" + with: + path: "~/.gradle/wrapper" + key: "${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}" + restore-keys: | + ${{ runner.os }}-gradlew- + - run: | + [[ "${{ github.event.release.tag_name }}" =~ ^[0-9]+(\.[0-9]+)*$ ]] || exit -1 + chmod +x gradlew + ./gradlew -Psign-required=true publish -Pversion="${{ github.event.release.tag_name }}" -PmavenCentralUsername="${{ secrets.MAVEN_CENTRAL_USERNAME }}" -PmavenCentralPassword="${{ secrets.MAVEN_CENTRAL_PASSWORD }}" -PsigningInMemoryKey="${{ secrets.GPG_PRIVATE_KEY_ARMORED }}" -PsigningInMemoryKeyPassword="${{ secrets.GPG_PASSPHRASE }}" diff --git a/build.gradle.kts b/build.gradle.kts index b2df6f0..ff3dd55 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ -plugins { - java -} +import net.infumia.gradle.spotless -subprojects { - apply() -} +plugins { java } + +subprojects { apply() } + +spotless() diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 0759ad7..16e1266 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,6 +1,4 @@ -plugins { - `kotlin-dsl` -} +plugins { `kotlin-dsl` } repositories { mavenCentral() @@ -11,8 +9,7 @@ dependencies { implementation(libs.nexus.plugin) implementation(libs.kotlin.plugin) implementation(libs.dokka.plugin) + implementation(libs.spotless.plugin) } -kotlin { - jvmToolchain(11) -} +kotlin { jvmToolchain(11) } diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index b5a0fab..65a9695 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,7 +1,3 @@ dependencyResolutionManagement { - versionCatalogs { - create("libs") { - from(files("../gradle/libs.versions.toml")) - } - } + versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) } } } diff --git a/buildSrc/src/main/kotlin/net/infumia/gradle/common.kt b/buildSrc/src/main/kotlin/net/infumia/gradle/common.kt index 1f81f5a..6286f5f 100644 --- a/buildSrc/src/main/kotlin/net/infumia/gradle/common.kt +++ b/buildSrc/src/main/kotlin/net/infumia/gradle/common.kt @@ -8,11 +8,7 @@ import org.gradle.jvm.toolchain.JavaLanguageVersion import org.gradle.kotlin.dsl.* import org.jetbrains.dokka.gradle.DokkaPlugin -fun Project.applyCommon( - javaVersion: Int = 8, - sources: Boolean = true, - javadoc: Boolean = true -) { +fun Project.applyCommon(javaVersion: Int = 8, sources: Boolean = true, javadoc: Boolean = true) { apply() if (name.contains("kotlin")) { @@ -23,25 +19,25 @@ fun Project.applyCommon( repositories.mavenCentral() extensions.configure { - toolchain { - languageVersion = JavaLanguageVersion.of(javaVersion) - } + toolchain { languageVersion = JavaLanguageVersion.of(javaVersion) } } if (javadoc) { - val javadocJar by tasks.creating(Jar::class) { - dependsOn("javadoc") - archiveClassifier.set("javadoc") - from(javadoc) - } + val javadocJar by + tasks.creating(Jar::class) { + dependsOn("javadoc") + archiveClassifier.set("javadoc") + from(javadoc) + } } if (sources) { val sourceSets = extensions.getByType().sourceSets - val sourcesJar by tasks.creating(Jar::class) { - dependsOn("classes") - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) - } + val sourcesJar by + tasks.creating(Jar::class) { + dependsOn("classes") + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) + } } } diff --git a/buildSrc/src/main/kotlin/net/infumia/gradle/spotless.kt b/buildSrc/src/main/kotlin/net/infumia/gradle/spotless.kt new file mode 100644 index 0000000..95553c9 --- /dev/null +++ b/buildSrc/src/main/kotlin/net/infumia/gradle/spotless.kt @@ -0,0 +1,91 @@ +package net.infumia.gradle + +import com.diffplug.gradle.spotless.SpotlessExtension +import com.diffplug.gradle.spotless.SpotlessPlugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.* + +fun Project.spotless() { + val subProjects = subprojects.map { it.projectDir.toRelativeString(projectDir) } + + repositories.mavenCentral() + + apply() + + extensions.configure { + isEnforceCheck = false + lineEndings = com.diffplug.spotless.LineEnding.UNIX + + val prettierConfig = + mapOf( + "prettier" to "3.3.2", + "prettier-plugin-java" to "2.6.0", + "prettier-plugin-toml" to "2.0.1", + ) + + yaml { + target(".github/**/*.yml") + endWithNewline() + trimTrailingWhitespace() + jackson().yamlFeature("LITERAL_BLOCK_STYLE", true).yamlFeature("SPLIT_LINES", false) + } + + json { + target("renovate.json") + endWithNewline() + trimTrailingWhitespace() + jackson() + } + + format("toml") { + target("gradle/libs.versions.toml") + endWithNewline() + trimTrailingWhitespace() + prettier(prettierConfig) + .config( + mapOf( + "parser" to "toml", + "plugins" to listOf("prettier-plugin-toml"), + ), + ) + } + + kotlin { + target( + "buildSrc/src/main/kotlin/**/*.kt", + "buildSrc/**/*.gradle.kts", + "*.gradle.kts", + *subProjects.map { "$it/*.gradle.kts" }.toTypedArray(), + *subProjects.map { "$it/src/main/kotlin/**/*.kt" }.toTypedArray(), + ) + endWithNewline() + trimTrailingWhitespace() + ktfmt().kotlinlangStyle().configure { + it.setMaxWidth(100) + it.setBlockIndent(4) + it.setContinuationIndent(4) + it.setRemoveUnusedImport(true) + } + } + + java { + target( + *subProjects.map { "$it/src/main/java/**/*.java" }.toTypedArray(), + ) + importOrder() + removeUnusedImports() + endWithNewline() + trimTrailingWhitespace() + prettier(prettierConfig) + .config( + mapOf( + "parser" to "java", + "tabWidth" to 4, + "useTabs" to false, + "printWidth" to 100, + "plugins" to listOf("prettier-plugin-java"), + ), + ) + } + } +} diff --git a/codec/src/main/java/net/infumia/pubsub/CodecProviderCached.java b/codec/src/main/java/net/infumia/pubsub/CodecProviderCached.java index f5e51eb..813f560 100644 --- a/codec/src/main/java/net/infumia/pubsub/CodecProviderCached.java +++ b/codec/src/main/java/net/infumia/pubsub/CodecProviderCached.java @@ -7,6 +7,7 @@ * A cached implementation of the {@link CodecProvider} interface. */ public final class CodecProviderCached implements CodecProvider { + private final Map, Codec> cache = new HashMap<>(); private final CodecProvider delegate; @@ -22,7 +23,6 @@ public CodecProviderCached(final CodecProvider delegate) { @Override @SuppressWarnings("unchecked") public Codec provide(final Class type) { - return (Codec) this.cache.computeIfAbsent(type, __ -> - this.delegate.provide(type)); + return (Codec) this.cache.computeIfAbsent(type, __ -> this.delegate.provide(type)); } } diff --git a/common/src/main/java/net/infumia/pubsub/AwaitingResponder.java b/common/src/main/java/net/infumia/pubsub/AwaitingResponder.java index dcd709c..f497b46 100644 --- a/common/src/main/java/net/infumia/pubsub/AwaitingResponder.java +++ b/common/src/main/java/net/infumia/pubsub/AwaitingResponder.java @@ -4,6 +4,7 @@ import java.util.concurrent.CompletableFuture; final class AwaitingResponder { + private final CompletableFuture future = new CompletableFuture<>(); final Class responseType; diff --git a/common/src/main/java/net/infumia/pubsub/Broker.java b/common/src/main/java/net/infumia/pubsub/Broker.java index d6bc188..275323a 100644 --- a/common/src/main/java/net/infumia/pubsub/Broker.java +++ b/common/src/main/java/net/infumia/pubsub/Broker.java @@ -73,8 +73,12 @@ public interface Broker extends AutoCloseable { * @param the type of the response. * @return a {@link CompletableFuture} representing the response. Cannot be {@code null} */ - CompletableFuture request(Object message, Class responseType, Duration timeout, - Collection targets); + CompletableFuture request( + Object message, + Class responseType, + Duration timeout, + Collection targets + ); /** * Sends a request and awaits a response within a timeout. @@ -86,7 +90,12 @@ CompletableFuture request(Object message, Class responseType, Duration * @param the type of the response. * @return a {@link CompletableFuture} representing the response. Cannot be {@code null} */ - CompletableFuture request(Object message, Class responseType, Duration timeout, Target... targets); + CompletableFuture request( + Object message, + Class responseType, + Duration timeout, + Target... targets + ); /** * Sends a request to targets and awaits a response using the default timeout. @@ -97,7 +106,11 @@ CompletableFuture request(Object message, Class responseType, Duration * @param the type of the response. * @return a {@link CompletableFuture} representing the response. Cannot be {@code null} */ - CompletableFuture request(Object message, Class responseType, Collection targets); + CompletableFuture request( + Object message, + Class responseType, + Collection targets + ); /** * Sends a request and awaits a response using the default timeout. diff --git a/common/src/main/java/net/infumia/pubsub/BrokerStringAbstract.java b/common/src/main/java/net/infumia/pubsub/BrokerStringAbstract.java index 8a31c18..80d4838 100644 --- a/common/src/main/java/net/infumia/pubsub/BrokerStringAbstract.java +++ b/common/src/main/java/net/infumia/pubsub/BrokerStringAbstract.java @@ -2,7 +2,6 @@ import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; - import java.time.Duration; import java.util.Arrays; import java.util.Collection; @@ -17,6 +16,7 @@ * and responding to messages. */ public abstract class BrokerStringAbstract implements Broker { + private final UUID brokerId = UUID.randomUUID(); private final HandlerRegistry handlerRegistry = new HandlerRegistry(); protected final Target responderTarget = Internal.responderTarget(this.brokerId); @@ -43,9 +43,9 @@ public final void initialize() { @Override public final void send(final Object message, final Collection targets) { this.sendEnvelope( - Internal.newEnvelope(this.codecProvider, this.brokerId, message), - this.channelsForMessage(message, targets) - ); + Internal.newEnvelope(this.codecProvider, this.brokerId, message), + this.channelsForMessage(message, targets) + ); } @Override @@ -66,14 +66,18 @@ public final AutoCloseable listen(final Handler handler) { @Override public AutoCloseable listen(final Class type, final Consumer handler) { return this.respond(type, message -> { - handler.accept(message); - return null; - }); + handler.accept(message); + return null; + }); } @Override - public final CompletableFuture request(final Object message, final Class responseType, - final Duration timeout, final Collection targets) { + public final CompletableFuture request( + final Object message, + final Class responseType, + final Duration timeout, + final Collection targets + ) { final Envelope envelope = Internal.newEnvelope(this.codecProvider, this.brokerId, message); final AwaitingResponder responder = new AwaitingResponder<>(responseType); this.awaitingResponders.put(envelope.messageId, responder); @@ -82,20 +86,30 @@ public final CompletableFuture request(final Object message, final Class< } @Override - public CompletableFuture request(final Object message, final Class responseType, final Duration timeout, - final Target... targets) { + public CompletableFuture request( + final Object message, + final Class responseType, + final Duration timeout, + final Target... targets + ) { return this.request(message, responseType, timeout, Arrays.asList(targets)); } @Override - public CompletableFuture request(final Object message, final Class responseType, - final Collection targets) { + public CompletableFuture request( + final Object message, + final Class responseType, + final Collection targets + ) { return this.request(message, responseType, Internal.REQUEST_TIMEOUT, targets); } @Override - public CompletableFuture request(final Object message, final Class responseType, - final Target... targets) { + public CompletableFuture request( + final Object message, + final Class responseType, + final Target... targets + ) { return this.request(message, responseType, Internal.REQUEST_TIMEOUT, targets); } @@ -106,17 +120,19 @@ public final AutoCloseable respond(final Responder responder) { @Override public AutoCloseable respond(final Class type, final Function responder) { - return this.respond(new Responder() { - @Override - public Class type() { - return type; - } + return this.respond( + new Responder() { + @Override + public Class type() { + return type; + } - @Override - public Y apply(final T message) { - return responder.apply(message); - } - }); + @Override + public Y apply(final T message) { + return responder.apply(message); + } + } + ); } @Override @@ -131,22 +147,25 @@ public void close() { * @param encodedData the encoded data representing the message. Cannot be {@code null}. */ protected final void callHandlers(final String channel, final String encodedData) { - final Envelope envelope = this.codecProvider.provide(Envelope.class).decode(Hex.decode(encodedData)); + final Envelope envelope = + this.codecProvider.provide(Envelope.class).decode(Hex.decode(encodedData)); if (envelope.respondsTo != null) { this.handleResponderEnvelope(envelope); return; } - final Collection> responders = this.handlerRegistry.get(this.messageTypeIdForChannel(channel)); + final Collection> responders = + this.handlerRegistry.get(this.messageTypeIdForChannel(channel)); if (responders == null) { return; } for (final Responder responder : responders) { final Envelope response = this.handleEnvelope(envelope, responder); if (response != null) { - final Collection previousChannel = this.channelsForMessage( - responder, - Collections.singleton(Internal.responderTarget(envelope.brokerId)) - ); + final Collection previousChannel = + this.channelsForMessage( + responder, + Collections.singleton(Internal.responderTarget(envelope.brokerId)) + ); this.sendEnvelope(response, previousChannel); } } @@ -164,7 +183,10 @@ protected final void callHandlers(final String channel, final String encodedData * @param targets the collection of targets to which the message should be sent. Cannot be {@code null}. * @return a collection of channel names. Cannot be {@code null}. */ - protected abstract Collection channelsFor(String messageTypeId, Collection targets); + protected abstract Collection channelsFor( + String messageTypeId, + Collection targets + ); /** * Retrieves the message type ID for the specified channel. @@ -183,34 +205,52 @@ protected final void callHandlers(final String channel, final String encodedData protected abstract void sendData(Collection channels, String serializedData); private void sendEnvelope(final Envelope envelope, final Collection channels) { - this.sendData(channels, Hex.encode(this.codecProvider.provide(Envelope.class).encode(envelope))); + this.sendData( + channels, + Hex.encode(this.codecProvider.provide(Envelope.class).encode(envelope)) + ); } private void handleResponderEnvelope(final Envelope envelope) { - final AwaitingResponder responder = this.awaitingResponders.getIfPresent(envelope.respondsTo); + final AwaitingResponder responder = + this.awaitingResponders.getIfPresent(envelope.respondsTo); if (responder != null) { this.handleResponderEnvelope(envelope, responder); } } - private void handleResponderEnvelope(final Envelope envelope, final AwaitingResponder responder) { - responder.complete(this.codecProvider.provide(responder.responseType).decode(envelope.messagePayload)); + private void handleResponderEnvelope( + final Envelope envelope, + final AwaitingResponder responder + ) { + responder.complete( + this.codecProvider.provide(responder.responseType).decode(envelope.messagePayload) + ); } private Envelope handleEnvelope( final Envelope envelope, final Responder responder ) { - final T decoded = this.codecProvider.provide(responder.type()).decode(envelope.messagePayload); + final T decoded = + this.codecProvider.provide(responder.type()).decode(envelope.messagePayload); final Y response = responder.apply(decoded); if (response == null) { return null; } else { - return Internal.newRespondingEnvelope(this.codecProvider, this.brokerId, envelope, response); + return Internal.newRespondingEnvelope( + this.codecProvider, + this.brokerId, + envelope, + response + ); } } - private Collection channelsForMessage(final Object message, final Collection targets) { + private Collection channelsForMessage( + final Object message, + final Collection targets + ) { return this.channelsFor(this.messageTypeId(message.getClass()), targets); } diff --git a/common/src/main/java/net/infumia/pubsub/Envelope.java b/common/src/main/java/net/infumia/pubsub/Envelope.java index 27170ed..dbd7afe 100644 --- a/common/src/main/java/net/infumia/pubsub/Envelope.java +++ b/common/src/main/java/net/infumia/pubsub/Envelope.java @@ -5,6 +5,7 @@ import java.util.UUID; final class Envelope { + UUID brokerId; UUID messageId; /** @@ -36,14 +37,21 @@ public boolean equals(final Object o) { return false; } final Envelope envelope = (Envelope) o; - return Objects.equals(this.brokerId, envelope.brokerId) && - Objects.equals(this.messageId, envelope.messageId) && - Objects.equals(this.respondsTo, envelope.respondsTo) && - Objects.deepEquals(this.messagePayload, envelope.messagePayload); + return ( + Objects.equals(this.brokerId, envelope.brokerId) && + Objects.equals(this.messageId, envelope.messageId) && + Objects.equals(this.respondsTo, envelope.respondsTo) && + Objects.deepEquals(this.messagePayload, envelope.messagePayload) + ); } @Override public int hashCode() { - return Objects.hash(this.brokerId, this.messageId, this.respondsTo, Arrays.hashCode(this.messagePayload)); + return Objects.hash( + this.brokerId, + this.messageId, + this.respondsTo, + Arrays.hashCode(this.messagePayload) + ); } } diff --git a/common/src/main/java/net/infumia/pubsub/HandlerRegistry.java b/common/src/main/java/net/infumia/pubsub/HandlerRegistry.java index 7fbc50b..1862860 100644 --- a/common/src/main/java/net/infumia/pubsub/HandlerRegistry.java +++ b/common/src/main/java/net/infumia/pubsub/HandlerRegistry.java @@ -5,6 +5,7 @@ import java.util.function.Supplier; final class HandlerRegistry { + private final ReentrantLock lock = new ReentrantLock(); private final MultiMap> handlers = new MultiMap<>(); @@ -23,12 +24,12 @@ void unregister(final String messageTypeId, final Responder handler) { Collection> get(final String messageTypeId) { return this.withLock(() -> { - final Collection> handlers = this.handlers.get(messageTypeId); - if (handlers == null || handlers.isEmpty()) { - return null; - } - return handlers; - }); + final Collection> handlers = this.handlers.get(messageTypeId); + if (handlers == null || handlers.isEmpty()) { + return null; + } + return handlers; + }); } private T withLock(final Supplier task) { diff --git a/common/src/main/java/net/infumia/pubsub/Hex.java b/common/src/main/java/net/infumia/pubsub/Hex.java index 93f2c9b..22e7552 100644 --- a/common/src/main/java/net/infumia/pubsub/Hex.java +++ b/common/src/main/java/net/infumia/pubsub/Hex.java @@ -27,7 +27,25 @@ * From */ final class Hex { - private static final char[] LOOKUP_TABLE_LOWER = new char[]{0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66}; + + private static final char[] LOOKUP_TABLE_LOWER = new char[] { + 0x30, + 0x31, + 0x32, + 0x33, + 0x34, + 0x35, + 0x36, + 0x37, + 0x38, + 0x39, + 0x61, + 0x62, + 0x63, + 0x64, + 0x65, + 0x66, + }; static String encode(final byte[] byteArray) { final char[] buffer = new char[byteArray.length * 2]; @@ -42,8 +60,11 @@ static String encode(final byte[] byteArray) { static byte[] decode(final CharSequence hexString) { int start; - if (Objects.requireNonNull(hexString).length() > 2 && - hexString.charAt(0) == '0' && hexString.charAt(1) == 'x') { + if ( + Objects.requireNonNull(hexString).length() > 2 && + hexString.charAt(0) == '0' && + hexString.charAt(1) == 'x' + ) { start = 2; } else { start = 0; @@ -68,9 +89,22 @@ static byte[] decode(final CharSequence hexString) { if (first4Bits == -1 || second4Bits == -1) { if (i == start && isOddLength) { - throw new IllegalArgumentException("'" + hexString.charAt(i + 1) + "' at index " + (i + 1) + " is not hex formatted"); + throw new IllegalArgumentException( + "'" + + hexString.charAt(i + 1) + + "' at index " + + (i + 1) + + " is not hex formatted" + ); } else { - throw new IllegalArgumentException("'" + hexString.charAt(i) + hexString.charAt(i + 1) + "' at index " + i + " is not hex formatted"); + throw new IllegalArgumentException( + "'" + + hexString.charAt(i) + + hexString.charAt(i + 1) + + "' at index " + + i + + " is not hex formatted" + ); } } diff --git a/common/src/main/java/net/infumia/pubsub/Internal.java b/common/src/main/java/net/infumia/pubsub/Internal.java index 9c8eeae..4bb9b4b 100644 --- a/common/src/main/java/net/infumia/pubsub/Internal.java +++ b/common/src/main/java/net/infumia/pubsub/Internal.java @@ -10,6 +10,7 @@ import java.util.concurrent.TimeoutException; final class Internal { + private static final ScheduledExecutorService DELAYER = Executors.newScheduledThreadPool(1); static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(10L); static final Duration RESPOND_TIMEOUT = Duration.ofMinutes(1L); diff --git a/common/src/main/java/net/infumia/pubsub/Lazy.java b/common/src/main/java/net/infumia/pubsub/Lazy.java index c1bc7f0..9cd4ab4 100644 --- a/common/src/main/java/net/infumia/pubsub/Lazy.java +++ b/common/src/main/java/net/infumia/pubsub/Lazy.java @@ -3,6 +3,7 @@ import java.util.function.Supplier; final class Lazy implements Supplier { + static Lazy of(final Supplier supplier) { return new Lazy<>(supplier); } diff --git a/common/src/main/java/net/infumia/pubsub/MultiMap.java b/common/src/main/java/net/infumia/pubsub/MultiMap.java index 2fbc725..8a6911a 100644 --- a/common/src/main/java/net/infumia/pubsub/MultiMap.java +++ b/common/src/main/java/net/infumia/pubsub/MultiMap.java @@ -6,6 +6,7 @@ import java.util.Map; final class MultiMap { + private final Map> map = new HashMap<>(); MultiMap() {} diff --git a/common/src/main/java/net/infumia/pubsub/Responder.java b/common/src/main/java/net/infumia/pubsub/Responder.java index 9a2ab7c..849c315 100644 --- a/common/src/main/java/net/infumia/pubsub/Responder.java +++ b/common/src/main/java/net/infumia/pubsub/Responder.java @@ -9,7 +9,6 @@ * @param the type of the response. */ public interface Responder extends Function { - /** * Retrieves the class type of the message being handled. * diff --git a/common/src/main/java/net/infumia/pubsub/TargetImpl.java b/common/src/main/java/net/infumia/pubsub/TargetImpl.java index abe11bf..6e1e686 100644 --- a/common/src/main/java/net/infumia/pubsub/TargetImpl.java +++ b/common/src/main/java/net/infumia/pubsub/TargetImpl.java @@ -1,6 +1,7 @@ package net.infumia.pubsub; final class TargetImpl implements Target { + static final Target GLOBAL = Target.of("", ""); private final String type; diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 098b228..116eb33 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -14,6 +14,7 @@ kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", nexus-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.29.0" } kotlin-plugin = { module = "org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin", version.ref = "kotlin" } dokka-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.20" } +spotless-plugin = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.25.0" } [plugins] kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" } diff --git a/jackson/src/main/java/net/infumia/pubsub/CodecJackson.java b/jackson/src/main/java/net/infumia/pubsub/CodecJackson.java index a4c2086..2de4e80 100644 --- a/jackson/src/main/java/net/infumia/pubsub/CodecJackson.java +++ b/jackson/src/main/java/net/infumia/pubsub/CodecJackson.java @@ -2,10 +2,10 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - import java.io.IOException; final class CodecJackson implements Codec { + private final ObjectMapper mapper; private final Class type; diff --git a/jackson/src/main/java/net/infumia/pubsub/CodecProviderJackson.java b/jackson/src/main/java/net/infumia/pubsub/CodecProviderJackson.java index 90853af..61e41bf 100644 --- a/jackson/src/main/java/net/infumia/pubsub/CodecProviderJackson.java +++ b/jackson/src/main/java/net/infumia/pubsub/CodecProviderJackson.java @@ -6,6 +6,7 @@ * A {@link CodecProvider} implementation that uses Jackson for JSON serialization and deserialization. */ public final class CodecProviderJackson implements CodecProvider { + private final JacksonProvider provider; /** diff --git a/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutines.kt b/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutines.kt index 0f816f6..cd2150a 100644 --- a/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutines.kt +++ b/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutines.kt @@ -4,12 +4,11 @@ import kotlin.reflect.KClass import kotlin.time.Duration /** - * Interface representing a coroutine-based message broker that supports sending, receiving, and responding to messages. + * Interface representing a coroutine-based message broker that supports sending, receiving, and + * responding to messages. */ interface BrokerCoroutines : AutoCloseable { - /** - * Initializes the message broker, performing any necessary setup or initialization tasks. - */ + /** Initializes the message broker, performing any necessary setup or initialization tasks. */ suspend fun initialize() /** @@ -122,11 +121,7 @@ interface BrokerCoroutines : AutoCloseable { * @param timeout the duration to wait for a response. * @return the response to the request. */ - suspend fun request( - message: Any, - responseType: KClass, - timeout: Duration - ): R + suspend fun request(message: Any, responseType: KClass, timeout: Duration): R /** * Sends a request and awaits a response using the default timeout. @@ -137,7 +132,11 @@ interface BrokerCoroutines : AutoCloseable { * @param targets the collection of targets to send the request to. * @return the response to the request. */ - suspend fun request(message: Any, responseType: KClass, targets: Collection): R + suspend fun request( + message: Any, + responseType: KClass, + targets: Collection + ): R /** * Sends a request and awaits a response using the default timeout. @@ -159,7 +158,11 @@ interface BrokerCoroutines : AutoCloseable { * @param targets the targets to send the request to. * @return the response to the request. */ - suspend fun request(message: Any, responseType: KClass, vararg targets: Pair): R + suspend fun request( + message: Any, + responseType: KClass, + vararg targets: Pair + ): R /** * Sends a request and awaits a response using the default timeout. @@ -190,11 +193,12 @@ interface BrokerCoroutines : AutoCloseable { * @param responder the suspend function to handle incoming messages and produce responses. * @return an [AutoCloseable] that can be used to unregister the responder. */ - suspend fun respond(type: KClass, responder: suspend (T) -> Y?): AutoCloseable + suspend fun respond( + type: KClass, + responder: suspend (T) -> Y? + ): AutoCloseable - /** - * Closes the message broker and releases any resources it holds. - */ + /** Closes the message broker and releases any resources it holds. */ override fun close() } @@ -247,10 +251,8 @@ suspend inline fun BrokerCoroutines.request( * @param timeout the duration to wait for a response. * @return the response to the request. */ -suspend inline fun BrokerCoroutines.request( - message: Any, - timeout: Duration -): R = request(message, R::class, timeout) +suspend inline fun BrokerCoroutines.request(message: Any, timeout: Duration): R = + request(message, R::class, timeout) /** * Sends a request and awaits a response using the default timeout. @@ -285,9 +287,8 @@ suspend inline fun BrokerCoroutines.request( * @param message the request message. * @return the response to the request. */ -suspend inline fun BrokerCoroutines.request( - message: Any -): R = request(message, R::class) +suspend inline fun BrokerCoroutines.request(message: Any): R = + request(message, R::class) /** * Registers a function to respond to incoming messages of a specific type. diff --git a/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutinesImpl.kt b/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutinesImpl.kt index 6a3670b..63267b1 100644 --- a/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutinesImpl.kt +++ b/kotlin/coroutines/src/main/kotlin/net/infumia/pubsub/BrokerCoroutinesImpl.kt @@ -34,22 +34,28 @@ internal class BrokerCoroutinesImpl( override suspend fun listen(handler: HandlerCoroutines): AutoCloseable = this.delegate.listen(handler.type.java) { scope.launch { handler(it) } } - override suspend fun listen(type: KClass, handler: suspend (T) -> Unit): AutoCloseable = - this.delegate.listen(type.java) { scope.launch { handler(it) } } + override suspend fun listen( + type: KClass, + handler: suspend (T) -> Unit + ): AutoCloseable = this.delegate.listen(type.java) { scope.launch { handler(it) } } override suspend fun request( message: Any, responseType: KClass, timeout: Duration, targets: Collection - ): R = this.delegate.request(message, responseType.java, timeout.toJavaDuration(), targets).await() + ): R = + this.delegate.request(message, responseType.java, timeout.toJavaDuration(), targets).await() override suspend fun request( message: Any, responseType: KClass, timeout: Duration, vararg targets: Target - ): R = this.delegate.request(message, responseType.java, timeout.toJavaDuration(), *targets).await() + ): R = + this.delegate + .request(message, responseType.java, timeout.toJavaDuration(), *targets) + .await() override suspend fun request( message: Any, @@ -57,50 +63,62 @@ internal class BrokerCoroutinesImpl( timeout: Duration, vararg targets: Pair ): R = - this.delegate.request( - message, - responseType.java, - timeout.toJavaDuration(), - targets.map { Target.of(it.first, it.second) } - ).await() - - override suspend fun request(message: Any, responseType: KClass, timeout: Duration): R = - this.delegate.request( - message, - responseType.java, - timeout.toJavaDuration() - ).await() - - override suspend fun request(message: Any, responseType: KClass, targets: Collection): R = + this.delegate + .request( + message, + responseType.java, + timeout.toJavaDuration(), + targets.map { Target.of(it.first, it.second) } + ) + .await() + + override suspend fun request( + message: Any, + responseType: KClass, + timeout: Duration + ): R = this.delegate.request(message, responseType.java, timeout.toJavaDuration()).await() + + override suspend fun request( + message: Any, + responseType: KClass, + targets: Collection + ): R = this.delegate.request(message, responseType.java, Internal.REQUEST_TIMEOUT, targets).await() - override suspend fun request(message: Any, responseType: KClass, vararg targets: Target): R = - this.delegate.request(message, responseType.java, Internal.REQUEST_TIMEOUT, *targets).await() + override suspend fun request( + message: Any, + responseType: KClass, + vararg targets: Target + ): R = + this.delegate + .request(message, responseType.java, Internal.REQUEST_TIMEOUT, *targets) + .await() override suspend fun request( message: Any, responseType: KClass, vararg targets: Pair ): R = - this.delegate.request( - message, - responseType.java, - Internal.REQUEST_TIMEOUT, - targets.map { Target.of(it.first, it.second) } - ).await() + this.delegate + .request( + message, + responseType.java, + Internal.REQUEST_TIMEOUT, + targets.map { Target.of(it.first, it.second) } + ) + .await() override suspend fun request(message: Any, responseType: KClass): R = - this.delegate.request( - message, - responseType.java, - Internal.REQUEST_TIMEOUT - ).await() + this.delegate.request(message, responseType.java, Internal.REQUEST_TIMEOUT).await() - override suspend fun respond(responder: ResponderCoroutines): AutoCloseable = - this.delegate.respond(responder.type.java) { scope.launch { responder(it) } } + override suspend fun respond( + responder: ResponderCoroutines + ): AutoCloseable = this.delegate.respond(responder.type.java) { scope.launch { responder(it) } } - override suspend fun respond(type: KClass, responder: suspend (T) -> Y?): AutoCloseable = - this.delegate.respond(type.java) { scope.launch { responder(it) } } + override suspend fun respond( + type: KClass, + responder: suspend (T) -> Y? + ): AutoCloseable = this.delegate.respond(type.java) { scope.launch { responder(it) } } override fun close() { this.delegate.close() diff --git a/kotlin/extensions/build.gradle.kts b/kotlin/extensions/build.gradle.kts index 3eefad9..634eacd 100644 --- a/kotlin/extensions/build.gradle.kts +++ b/kotlin/extensions/build.gradle.kts @@ -2,6 +2,4 @@ import net.infumia.gradle.publish publish("kotlin") -dependencies { - compileOnly(project(":common")) -} +dependencies { compileOnly(project(":common")) } diff --git a/kotlin/extensions/src/main/kotlin/net/infumia/pubsub/BrokerExtension.kt b/kotlin/extensions/src/main/kotlin/net/infumia/pubsub/BrokerExtension.kt index f3f3857..fcc1829 100644 --- a/kotlin/extensions/src/main/kotlin/net/infumia/pubsub/BrokerExtension.kt +++ b/kotlin/extensions/src/main/kotlin/net/infumia/pubsub/BrokerExtension.kt @@ -30,8 +30,10 @@ inline fun Broker.listen(noinline handler: (T) -> Unit): AutoC * @param R the type of the expected response. * @return a [CompletableFuture] representing the response to the message. */ -inline fun Broker.request(message: Any, vararg targets: Target): CompletableFuture = - this.request(message, R::class.java, *targets) +inline fun Broker.request( + message: Any, + vararg targets: Target +): CompletableFuture = this.request(message, R::class.java, *targets) /** * Sends a message and expects a specific response. @@ -41,7 +43,10 @@ inline fun Broker.request(message: Any, vararg targets: Target * @param R the type of the expected response. * @return a [CompletableFuture] representing the response to the message. */ -inline fun Broker.request(message: Any, vararg targets: Pair): CompletableFuture = +inline fun Broker.request( + message: Any, + vararg targets: Pair +): CompletableFuture = this.request(message, R::class.java, targets.map { Target.of(it.first, it.second) }) /** @@ -57,7 +62,8 @@ inline fun Broker.request(message: Any): CompletableFuture /** * Registers a function to respond to messages of a specific type. * - * @param handler the function to handle incoming messages of type [T] and produce a response of type [R]. + * @param handler the function to handle incoming messages of type [T] and produce a response of + * type [R]. * @param T the type of the message to respond to. * @param R the type of the response. * @return an [AutoCloseable] that can be used to unregister the responder. diff --git a/kotlin/protobuf/build.gradle.kts b/kotlin/protobuf/build.gradle.kts index f63b1ad..9e4b00b 100644 --- a/kotlin/protobuf/build.gradle.kts +++ b/kotlin/protobuf/build.gradle.kts @@ -1,8 +1,6 @@ import net.infumia.gradle.publish -plugins { - alias(libs.plugins.kotlin.serialization) -} +plugins { alias(libs.plugins.kotlin.serialization) } publish("kotlin-protobuf") diff --git a/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodec.kt b/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodec.kt index 8039602..0048d14 100644 --- a/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodec.kt +++ b/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodec.kt @@ -5,12 +5,8 @@ import kotlinx.serialization.KSerializer import kotlinx.serialization.protobuf.ProtoBuf @OptIn(ExperimentalSerializationApi::class) -internal class ProtobufCodec( - private val serializer: KSerializer -) : Codec { - override fun encode(message: T): ByteArray = - ProtoBuf.encodeToByteArray(serializer, message) +internal class ProtobufCodec(private val serializer: KSerializer) : Codec { + override fun encode(message: T): ByteArray = ProtoBuf.encodeToByteArray(serializer, message) - override fun decode(message: ByteArray): T = - ProtoBuf.decodeFromByteArray(serializer, message) + override fun decode(message: ByteArray): T = ProtoBuf.decodeFromByteArray(serializer, message) } diff --git a/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodecProvider.kt b/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodecProvider.kt index 2dbeb4f..6e88778 100644 --- a/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodecProvider.kt +++ b/kotlin/protobuf/src/main/kotlin/net/infumia/pubsub/ProtobufCodecProvider.kt @@ -10,5 +10,7 @@ import kotlinx.serialization.serializer @OptIn(ExperimentalSerializationApi::class) class ProtobufCodecProvider : CodecProvider { override fun provide(type: Class): Codec = - ProtobufCodec(ProtoBuf.serializersModule.serializer(type.kotlin.createType()) as KSerializer) + ProtobufCodec( + ProtoBuf.serializersModule.serializer(type.kotlin.createType()) as KSerializer + ) } diff --git a/redis/src/main/java/net/infumia/pubsub/BrokerRedis.java b/redis/src/main/java/net/infumia/pubsub/BrokerRedis.java index fee8c63..cb65ebe 100644 --- a/redis/src/main/java/net/infumia/pubsub/BrokerRedis.java +++ b/redis/src/main/java/net/infumia/pubsub/BrokerRedis.java @@ -4,7 +4,6 @@ import io.lettuce.core.api.StatefulRedisConnection; import io.lettuce.core.pubsub.RedisPubSubAdapter; import io.lettuce.core.pubsub.StatefulRedisPubSubConnection; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -15,6 +14,7 @@ * Abstract class for a Redis-based message broker. */ public abstract class BrokerRedis extends BrokerStringAbstract { + private final Lazy> channelPrefixes; private final RedisClientProvider clientProvider; private final Executor executor; @@ -29,8 +29,11 @@ public abstract class BrokerRedis extends BrokerStringAbstract { * @param clientProvider the RedisClientProvider used for getting Redis client connections. Cannot be null. * @param executor the Executor used for calling handlers whenever redis receives a messages. Can be null. */ - public BrokerRedis(final CodecProvider codecProvider, final RedisClientProvider clientProvider, - final Executor executor) { + public BrokerRedis( + final CodecProvider codecProvider, + final RedisClientProvider clientProvider, + final Executor executor + ) { super(codecProvider); this.clientProvider = clientProvider; this.executor = executor; @@ -55,7 +58,10 @@ public BrokerRedis(final CodecProvider codecProvider, final RedisClientProvider * @param codecProvider the CodecProvider used for encoding and decoding messages. Cannot be null. * @param clientProvider the RedisClientProvider used for getting Redis client connections. Cannot be null. */ - public BrokerRedis(final CodecProvider codecProvider, final RedisClientProvider clientProvider) { + public BrokerRedis( + final CodecProvider codecProvider, + final RedisClientProvider clientProvider + ) { this(codecProvider, clientProvider, null); } @@ -66,35 +72,48 @@ protected void connect() { this.publishConnection = client.connect(); this.subscribeConnection = client.connectPubSub(); - this.subscribeConnection.addListener(new RedisPubSubAdapter() { - @Override - public void message(final String pattern, final String channel, final String message) { - if (executor == null) { - BrokerRedis.this.callHandlers(channel, message); - } else { - executor.execute(() -> BrokerRedis.this.callHandlers(channel, message)); + this.subscribeConnection.addListener( + new RedisPubSubAdapter() { + @Override + public void message( + final String pattern, + final String channel, + final String message + ) { + if (executor == null) { + BrokerRedis.this.callHandlers(channel, message); + } else { + executor.execute(() -> BrokerRedis.this.callHandlers(channel, message)); + } + } } - } - }); - final String[] channels = this.channelPrefixes.get().stream() - .map(s -> s + "*") - .toArray(String[]::new); + ); + final String[] channels = + this.channelPrefixes.get().stream().map(s -> s + "*").toArray(String[]::new); this.subscribeConnection.sync().psubscribe(channels); } @Override - protected Collection channelsFor(final String messageTypeId, final Collection targets) { - return Internal.channelPrefixFor(targets).stream() + protected Collection channelsFor( + final String messageTypeId, + final Collection targets + ) { + return Internal.channelPrefixFor(targets) + .stream() .map(s -> s + messageTypeId) .collect(Collectors.toList()); } @Override protected String messageTypeIdForChannel(final String channel) { - final String prefix = this.channelPrefixes.get().stream() - .filter(channel::startsWith) - .findFirst() - .orElseThrow(() -> new IllegalStateException("No channel prefix found for " + channel)); + final String prefix = + this.channelPrefixes.get() + .stream() + .filter(channel::startsWith) + .findFirst() + .orElseThrow( + () -> new IllegalStateException("No channel prefix found for " + channel) + ); return channel.substring(prefix.length()); } @@ -120,6 +139,7 @@ public void close() { protected abstract TargetProvider targetProvider(); private static final class Internal { + private static final String CHANNEL_PREFIX = "Messaging:"; private static final String GLOBAL_PREFIX = "Global:"; private static final String TARGET_PREFIX = "Target:"; @@ -128,13 +148,15 @@ private static Collection channelPrefixFor(final Collection targ if (targets.isEmpty()) { return Collections.singletonList(Internal.CHANNEL_PREFIX + Internal.GLOBAL_PREFIX); } - return targets.stream() - .map(target -> - Internal.CHANNEL_PREFIX + - Internal.TARGET_PREFIX + - target.type() + - ":" + - target.identifier() + return targets + .stream() + .map( + target -> + Internal.CHANNEL_PREFIX + + Internal.TARGET_PREFIX + + target.type() + + ":" + + target.identifier() ) .collect(Collectors.toList()); } diff --git a/redis/src/main/java/net/infumia/pubsub/BrokerRedisNoTargetProvider.java b/redis/src/main/java/net/infumia/pubsub/BrokerRedisNoTargetProvider.java index f70bda6..539b1c5 100644 --- a/redis/src/main/java/net/infumia/pubsub/BrokerRedisNoTargetProvider.java +++ b/redis/src/main/java/net/infumia/pubsub/BrokerRedisNoTargetProvider.java @@ -6,6 +6,7 @@ * A concrete implementation of {@link BrokerRedis} that does not provide a target provider. */ public final class BrokerRedisNoTargetProvider extends BrokerRedis { + /** * Ctor. * @@ -13,8 +14,11 @@ public final class BrokerRedisNoTargetProvider extends BrokerRedis { * @param clientProvider the RedisClientProvider used for obtaining Redis client connections. * @param executor the Executor used for calling handlers whenever redis receives a messages. Can be null. */ - public BrokerRedisNoTargetProvider(final CodecProvider codecProvider, final RedisClientProvider clientProvider, - final Executor executor) { + public BrokerRedisNoTargetProvider( + final CodecProvider codecProvider, + final RedisClientProvider clientProvider, + final Executor executor + ) { super(codecProvider, clientProvider, executor); } @@ -24,7 +28,10 @@ public BrokerRedisNoTargetProvider(final CodecProvider codecProvider, final Redi * @param codecProvider the CodecProvider used for encoding and decoding messages. * @param clientProvider the RedisClientProvider used for obtaining Redis client connections. */ - public BrokerRedisNoTargetProvider(final CodecProvider codecProvider, final RedisClientProvider clientProvider) { + public BrokerRedisNoTargetProvider( + final CodecProvider codecProvider, + final RedisClientProvider clientProvider + ) { super(codecProvider, clientProvider); } diff --git a/renovate.json b/renovate.json index 8f82b0a..2e0f7b2 100644 --- a/renovate.json +++ b/renovate.json @@ -1,18 +1,10 @@ { - "extends": [ - "config:base" - ], - "labels": ["dependencies"], - "schedule": [ - "after 9am" - ], - "packageRules": [ - { - "matchUpdateTypes": ["major", "minor", "patch", "pin", "digest", "lockFileMaintenance", "rollback", "bump"], - "automerge": true - } - ], - "ignorePaths": [ - "example" - ] -} + "extends": [ "config:base" ], + "labels": [ "dependencies" ], + "schedule": [ "after 9am" ], + "packageRules": [ { + "matchUpdateTypes": [ "major", "minor", "patch", "pin", "digest", "lockFileMaintenance", "rollback", "bump" ], + "automerge": true + } ], + "ignorePaths": [ "example" ] +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index a9cd125..0848e1b 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,11 +1,19 @@ -plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" -} +plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" } rootProject.name = "pubsub" -include("codec", "common", "redis", "jackson", "kotlin-extensions", "kotlin-coroutines", "kotlin-protobuf") +include( + "codec", + "common", + "redis", + "jackson", + "kotlin-extensions", + "kotlin-coroutines", + "kotlin-protobuf" +) project(":kotlin-extensions").projectDir = file("kotlin/extensions") + project(":kotlin-coroutines").projectDir = file("kotlin/coroutines") + project(":kotlin-protobuf").projectDir = file("kotlin/protobuf")