mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-27 13:15:44 +01:00
Implement messenger using Postgres listen/notify (#3641)
This commit is contained in:
parent
4068c71d5a
commit
90392511ef
@ -29,7 +29,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -39,7 +39,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -31,7 +31,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -57,6 +57,7 @@ dependencies {
|
|||||||
api 'com.squareup.okhttp3:okhttp:3.14.9'
|
api 'com.squareup.okhttp3:okhttp:3.14.9'
|
||||||
api 'com.squareup.okio:okio:1.17.5'
|
api 'com.squareup.okio:okio:1.17.5'
|
||||||
api 'net.bytebuddy:byte-buddy:1.10.22'
|
api 'net.bytebuddy:byte-buddy:1.10.22'
|
||||||
|
|
||||||
api('org.spongepowered:configurate-core:3.7.2') {
|
api('org.spongepowered:configurate-core:3.7.2') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
@ -72,10 +73,11 @@ dependencies {
|
|||||||
api('me.lucko.configurate:configurate-toml:3.7') {
|
api('me.lucko.configurate:configurate-toml:3.7') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
api 'com.zaxxer:HikariCP:4.0.3'
|
compileOnly 'com.zaxxer:HikariCP:4.0.3'
|
||||||
api 'redis.clients:jedis:3.5.2'
|
compileOnly 'redis.clients:jedis:3.5.2'
|
||||||
api 'io.nats:jnats:2.16.4'
|
compileOnly 'io.nats:jnats:2.16.4'
|
||||||
api 'com.rabbitmq:amqp-client:5.12.0'
|
compileOnly 'com.rabbitmq:amqp-client:5.12.0'
|
||||||
api 'org.mongodb:mongodb-driver-legacy:4.5.0'
|
compileOnly 'org.mongodb:mongodb-driver-legacy:4.5.0'
|
||||||
api 'org.yaml:snakeyaml:1.28'
|
compileOnly 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9'
|
||||||
|
compileOnly 'org.yaml:snakeyaml:1.28'
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.dependencies;
|
package me.lucko.luckperms.common.dependencies;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.RelocationHelper;
|
import me.lucko.luckperms.common.dependencies.relocation.RelocationHelper;
|
||||||
|
|
||||||
@ -154,11 +153,18 @@ public enum Dependency {
|
|||||||
Relocation.of("mysql", "com{}mysql")
|
Relocation.of("mysql", "com{}mysql")
|
||||||
),
|
),
|
||||||
POSTGRESQL_DRIVER(
|
POSTGRESQL_DRIVER(
|
||||||
"org{}postgresql",
|
"com{}impossibl{}pgjdbc-ng",
|
||||||
"postgresql",
|
"pgjdbc-ng",
|
||||||
"42.2.19",
|
"0.8.9",
|
||||||
"IydH+gkk2Iom36QrgSi2+hFAgC2AQSWJFZboyl8pEyI=",
|
"WEYMezl02Rot2n2ATs7NABcvL9ceQ/oLA/XPduIEaWA=",
|
||||||
Relocation.of("postgresql", "org{}postgresql")
|
Relocation.of("postgresql", "com{}impossibl")
|
||||||
|
),
|
||||||
|
POSTGRESQL_DRIVER_SPY(
|
||||||
|
"com{}impossibl{}pgjdbc-ng",
|
||||||
|
"spy",
|
||||||
|
"0.8.9",
|
||||||
|
"72ZuhpMy/4EYJZuSjBjGI5NGgdWmOpwjDHW9ISnqso8=",
|
||||||
|
Relocation.of("postgresql", "com{}impossibl")
|
||||||
),
|
),
|
||||||
H2_DRIVER_LEGACY(
|
H2_DRIVER_LEGACY(
|
||||||
"com.h2database",
|
"com.h2database",
|
||||||
|
@ -29,11 +29,9 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.collect.SetMultimap;
|
import com.google.common.collect.SetMultimap;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
import me.lucko.luckperms.common.dependencies.relocation.Relocation;
|
||||||
import me.lucko.luckperms.common.dependencies.relocation.RelocationHandler;
|
import me.lucko.luckperms.common.dependencies.relocation.RelocationHandler;
|
||||||
import me.lucko.luckperms.common.storage.StorageType;
|
import me.lucko.luckperms.common.storage.StorageType;
|
||||||
|
|
||||||
import net.luckperms.api.platform.Platform;
|
import net.luckperms.api.platform.Platform;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@ -57,7 +55,7 @@ public class DependencyRegistry {
|
|||||||
.putAll(StorageType.MONGODB, Dependency.MONGODB_DRIVER_CORE, Dependency.MONGODB_DRIVER_LEGACY, Dependency.MONGODB_DRIVER_SYNC, Dependency.MONGODB_DRIVER_BSON)
|
.putAll(StorageType.MONGODB, Dependency.MONGODB_DRIVER_CORE, Dependency.MONGODB_DRIVER_LEGACY, Dependency.MONGODB_DRIVER_SYNC, Dependency.MONGODB_DRIVER_BSON)
|
||||||
.putAll(StorageType.MARIADB, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.MARIADB_DRIVER)
|
.putAll(StorageType.MARIADB, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.MARIADB_DRIVER)
|
||||||
.putAll(StorageType.MYSQL, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.MYSQL_DRIVER)
|
.putAll(StorageType.MYSQL, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.MYSQL_DRIVER)
|
||||||
.putAll(StorageType.POSTGRESQL, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.POSTGRESQL_DRIVER)
|
.putAll(StorageType.POSTGRESQL, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI, Dependency.POSTGRESQL_DRIVER, Dependency.POSTGRESQL_DRIVER_SPY)
|
||||||
.putAll(StorageType.SQLITE, Dependency.SQLITE_DRIVER)
|
.putAll(StorageType.SQLITE, Dependency.SQLITE_DRIVER)
|
||||||
.putAll(StorageType.H2, Dependency.H2_DRIVER)
|
.putAll(StorageType.H2, Dependency.H2_DRIVER)
|
||||||
.build();
|
.build();
|
||||||
|
@ -28,6 +28,7 @@ package me.lucko.luckperms.common.messaging;
|
|||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
import me.lucko.luckperms.common.config.LuckPermsConfiguration;
|
||||||
import me.lucko.luckperms.common.messaging.nats.NatsMessenger;
|
import me.lucko.luckperms.common.messaging.nats.NatsMessenger;
|
||||||
|
import me.lucko.luckperms.common.messaging.postgres.PostgresMessenger;
|
||||||
import me.lucko.luckperms.common.messaging.rabbitmq.RabbitMQMessenger;
|
import me.lucko.luckperms.common.messaging.rabbitmq.RabbitMQMessenger;
|
||||||
import me.lucko.luckperms.common.messaging.redis.RedisMessenger;
|
import me.lucko.luckperms.common.messaging.redis.RedisMessenger;
|
||||||
import me.lucko.luckperms.common.messaging.sql.SqlMessenger;
|
import me.lucko.luckperms.common.messaging.sql.SqlMessenger;
|
||||||
@ -37,6 +38,7 @@ import me.lucko.luckperms.common.storage.implementation.sql.SqlStorage;
|
|||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MariaDbConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MariaDbConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MySqlConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MySqlConnectionFactory;
|
||||||
|
|
||||||
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.PostgresConnectionFactory;
|
||||||
import net.luckperms.api.messenger.IncomingMessageConsumer;
|
import net.luckperms.api.messenger.IncomingMessageConsumer;
|
||||||
import net.luckperms.api.messenger.Messenger;
|
import net.luckperms.api.messenger.Messenger;
|
||||||
import net.luckperms.api.messenger.MessengerProvider;
|
import net.luckperms.api.messenger.MessengerProvider;
|
||||||
@ -78,6 +80,10 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
|||||||
messagingType = "sql";
|
messagingType = "sql";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (sql.getConnectionFactory() instanceof PostgresConnectionFactory) {
|
||||||
|
messagingType = "postgresql";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,6 +144,12 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
getPlugin().getLogger().severe("Exception occurred whilst enabling SQL messaging service", e);
|
getPlugin().getLogger().severe("Exception occurred whilst enabling SQL messaging service", e);
|
||||||
}
|
}
|
||||||
|
} else if (messagingType.equals("postgresql")) {
|
||||||
|
try {
|
||||||
|
return new LuckPermsMessagingService(this.plugin, new PostgresMessengerProvider());
|
||||||
|
} catch (Exception e) {
|
||||||
|
getPlugin().getLogger().severe("Exception occurred whilst enabling Postgres messaging service", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -246,4 +258,29 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class PostgresMessengerProvider implements MessengerProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull String getName() {
|
||||||
|
return "PostgreSQL";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull Messenger obtain(@NonNull IncomingMessageConsumer incomingMessageConsumer) {
|
||||||
|
for (StorageImplementation implementation : getPlugin().getStorage().getImplementations()) {
|
||||||
|
if (implementation instanceof SqlStorage) {
|
||||||
|
SqlStorage storage = (SqlStorage) implementation;
|
||||||
|
if (storage.getConnectionFactory() instanceof PostgresConnectionFactory) {
|
||||||
|
// found an implementation match!
|
||||||
|
PostgresMessenger messenger = new PostgresMessenger(getPlugin(), storage, incomingMessageConsumer);
|
||||||
|
messenger.init();
|
||||||
|
return messenger;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IllegalStateException("Can't find a supported sql storage implementation");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,169 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of LuckPerms, licensed under the MIT License.
|
||||||
|
*
|
||||||
|
* Copyright (c) lucko (Luck) <luck@lucko.me>
|
||||||
|
* Copyright (c) contributors
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package me.lucko.luckperms.common.messaging.postgres;
|
||||||
|
|
||||||
|
import com.impossibl.postgres.api.jdbc.PGConnection;
|
||||||
|
import com.impossibl.postgres.api.jdbc.PGNotificationListener;
|
||||||
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
|
import me.lucko.luckperms.common.plugin.scheduler.SchedulerTask;
|
||||||
|
import me.lucko.luckperms.common.storage.implementation.sql.SqlStorage;
|
||||||
|
import net.luckperms.api.messenger.IncomingMessageConsumer;
|
||||||
|
import net.luckperms.api.messenger.Messenger;
|
||||||
|
import net.luckperms.api.messenger.message.OutgoingMessage;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An implementation of {@link Messenger} using Postgres.
|
||||||
|
*/
|
||||||
|
public class PostgresMessenger implements Messenger {
|
||||||
|
|
||||||
|
private static final String CHANNEL = "luckperms:update";
|
||||||
|
|
||||||
|
private final LuckPermsPlugin plugin;
|
||||||
|
private final SqlStorage sqlStorage;
|
||||||
|
private final IncomingMessageConsumer consumer;
|
||||||
|
|
||||||
|
private NotificationListener listener;
|
||||||
|
private SchedulerTask checkConnectionTask;
|
||||||
|
|
||||||
|
public PostgresMessenger(LuckPermsPlugin plugin, SqlStorage sqlStorage, IncomingMessageConsumer consumer) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.sqlStorage = sqlStorage;
|
||||||
|
this.consumer = consumer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init() {
|
||||||
|
checkAndReopenConnection(true);
|
||||||
|
this.checkConnectionTask = this.plugin.getBootstrap().getScheduler().asyncRepeating(() -> checkAndReopenConnection(false), 5, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendOutgoingMessage(@NonNull OutgoingMessage outgoingMessage) {
|
||||||
|
try (PGConnection connection = this.sqlStorage.getConnectionFactory().getConnection().unwrap(PGConnection.class)) {
|
||||||
|
try (PreparedStatement ps = connection.prepareStatement("SELECT pg_notify(?, ?)")) {
|
||||||
|
ps.setString(1, CHANNEL);
|
||||||
|
ps.setString(2, outgoingMessage.asEncodedString());
|
||||||
|
ps.execute();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
try {
|
||||||
|
this.checkConnectionTask.cancel();
|
||||||
|
if (this.listener != null) {
|
||||||
|
this.listener.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks the connection, and re-opens it if necessary.
|
||||||
|
*
|
||||||
|
* @return true if the connection is now alive, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean checkAndReopenConnection(boolean firstStartup) {
|
||||||
|
boolean listenerActive = this.listener != null && this.listener.isListening();
|
||||||
|
if (listenerActive) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// (re)create
|
||||||
|
|
||||||
|
if (!firstStartup) {
|
||||||
|
this.plugin.getLogger().warn("Postgres listen/notify connection dropped, trying to re-open the connection");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.listener = new NotificationListener();
|
||||||
|
this.plugin.getBootstrap().getScheduler().executeAsync(() -> {
|
||||||
|
this.listener.listenAndBind();
|
||||||
|
if (!firstStartup) {
|
||||||
|
this.plugin.getLogger().info("Postgres listen/notify connection re-established");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class NotificationListener implements PGNotificationListener, AutoCloseable {
|
||||||
|
private final CountDownLatch latch = new CountDownLatch(1);
|
||||||
|
private final AtomicBoolean listening = new AtomicBoolean(false);
|
||||||
|
|
||||||
|
public void listenAndBind() {
|
||||||
|
try (PGConnection connection = PostgresMessenger.this.sqlStorage.getConnectionFactory().getConnection().unwrap(PGConnection.class)) {
|
||||||
|
connection.addNotificationListener(CHANNEL, this);
|
||||||
|
|
||||||
|
try (Statement s = connection.createStatement()) {
|
||||||
|
s.execute("LISTEN \"" + CHANNEL + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.listening.set(true);
|
||||||
|
this.latch.await();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
this.listening.set(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isListening() {
|
||||||
|
return this.listening.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notification(int processId, String channelName, String payload) {
|
||||||
|
if (!CHANNEL.equals(channelName)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PostgresMessenger.this.consumer.consumeIncomingMessageAsString(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void closed() {
|
||||||
|
this.latch.countDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
this.latch.countDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.storage;
|
package me.lucko.luckperms.common.storage;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.storage.implementation.StorageImplementation;
|
import me.lucko.luckperms.common.storage.implementation.StorageImplementation;
|
||||||
@ -45,7 +44,7 @@ import me.lucko.luckperms.common.storage.implementation.sql.connection.file.H2Co
|
|||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.file.SqliteConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.file.SqliteConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MariaDbConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MariaDbConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MySqlConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.MySqlConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.PostgreConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.hikari.PostgresConnectionFactory;
|
||||||
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
import me.lucko.luckperms.common.util.ImmutableCollectors;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -120,7 +119,7 @@ public class StorageFactory {
|
|||||||
case POSTGRESQL:
|
case POSTGRESQL:
|
||||||
return new SqlStorage(
|
return new SqlStorage(
|
||||||
this.plugin,
|
this.plugin,
|
||||||
new PostgreConnectionFactory(this.plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
|
new PostgresConnectionFactory(this.plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
|
||||||
this.plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
|
this.plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
|
||||||
);
|
);
|
||||||
case MONGODB:
|
case MONGODB:
|
||||||
|
@ -28,13 +28,11 @@ package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
|||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.locale.Message;
|
import me.lucko.luckperms.common.locale.Message;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
import me.lucko.luckperms.common.plugin.logging.PluginLogger;
|
||||||
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
import me.lucko.luckperms.common.storage.implementation.sql.connection.ConnectionFactory;
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
@ -84,7 +82,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
*
|
*
|
||||||
* @param properties the current properties
|
* @param properties the current properties
|
||||||
*/
|
*/
|
||||||
protected void overrideProperties(Map<String, String> properties) {
|
protected void overrideProperties(Map<String, Object> properties) {
|
||||||
// https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery
|
// https://github.com/brettwooldridge/HikariCP/wiki/Rapid-Recovery
|
||||||
properties.putIfAbsent("socketTimeout", String.valueOf(TimeUnit.SECONDS.toMillis(30)));
|
properties.putIfAbsent("socketTimeout", String.valueOf(TimeUnit.SECONDS.toMillis(30)));
|
||||||
}
|
}
|
||||||
@ -95,8 +93,8 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
* @param config the hikari config
|
* @param config the hikari config
|
||||||
* @param properties the properties
|
* @param properties the properties
|
||||||
*/
|
*/
|
||||||
protected void setProperties(HikariConfig config, Map<String, String> properties) {
|
protected void setProperties(HikariConfig config, Map<String, Object> properties) {
|
||||||
for (Map.Entry<String, String> property : properties.entrySet()) {
|
for (Map.Entry<String, Object> property : properties.entrySet()) {
|
||||||
config.addDataSourceProperty(property.getKey(), property.getValue());
|
config.addDataSourceProperty(property.getKey(), property.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,7 +132,7 @@ public abstract class HikariConnectionFactory implements ConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get the extra connection properties from the config
|
// get the extra connection properties from the config
|
||||||
Map<String, String> properties = new HashMap<>(this.configuration.getProperties());
|
Map<String, Object> properties = new HashMap<>(this.configuration.getProperties());
|
||||||
|
|
||||||
// allow the implementation to override/make changes to these properties
|
// allow the implementation to override/make changes to these properties
|
||||||
overrideProperties(properties);
|
overrideProperties(properties);
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -59,7 +58,7 @@ public class MariaDbConnectionFactory extends HikariConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setProperties(HikariConfig config, Map<String, String> properties) {
|
protected void setProperties(HikariConfig config, Map<String, Object> properties) {
|
||||||
String propertiesString = properties.entrySet().stream()
|
String propertiesString = properties.entrySet().stream()
|
||||||
.map(e -> e.getKey() + "=" + e.getValue())
|
.map(e -> e.getKey() + "=" + e.getValue())
|
||||||
.collect(Collectors.joining(";"));
|
.collect(Collectors.joining(";"));
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
import java.sql.Driver;
|
import java.sql.Driver;
|
||||||
@ -80,7 +79,7 @@ public class MySqlConnectionFactory extends HikariConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void overrideProperties(Map<String, String> properties) {
|
protected void overrideProperties(Map<String, Object> properties) {
|
||||||
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
|
// https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration
|
||||||
properties.putIfAbsent("cachePrepStmts", "true");
|
properties.putIfAbsent("cachePrepStmts", "true");
|
||||||
properties.putIfAbsent("prepStmtCacheSize", "250");
|
properties.putIfAbsent("prepStmtCacheSize", "250");
|
||||||
|
@ -26,14 +26,13 @@
|
|||||||
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
package me.lucko.luckperms.common.storage.implementation.sql.connection.hikari;
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig;
|
import com.zaxxer.hikari.HikariConfig;
|
||||||
|
|
||||||
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
import me.lucko.luckperms.common.storage.misc.StorageCredentials;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
public class PostgreConnectionFactory extends HikariConnectionFactory {
|
public class PostgresConnectionFactory extends HikariConnectionFactory {
|
||||||
public PostgreConnectionFactory(StorageCredentials configuration) {
|
public PostgresConnectionFactory(StorageCredentials configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,21 +48,27 @@ public class PostgreConnectionFactory extends HikariConnectionFactory {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configureDatabase(HikariConfig config, String address, String port, String databaseName, String username, String password) {
|
protected void configureDatabase(HikariConfig config, String address, String port, String databaseName, String username, String password) {
|
||||||
config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource");
|
config.setDataSourceClassName("com.impossibl.postgres.jdbc.PGDataSource");
|
||||||
config.addDataSourceProperty("serverName", address);
|
config.addDataSourceProperty("serverName", address);
|
||||||
config.addDataSourceProperty("portNumber", port);
|
config.addDataSourceProperty("portNumber", Integer.parseInt(port));
|
||||||
config.addDataSourceProperty("databaseName", databaseName);
|
config.addDataSourceProperty("databaseName", databaseName);
|
||||||
config.addDataSourceProperty("user", username);
|
config.addDataSourceProperty("user", username);
|
||||||
config.addDataSourceProperty("password", password);
|
config.addDataSourceProperty("password", password);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void overrideProperties(Map<String, String> properties) {
|
protected void overrideProperties(Map<String, Object> properties) {
|
||||||
super.overrideProperties(properties);
|
super.overrideProperties(properties);
|
||||||
|
|
||||||
// remove the default config properties which don't exist for PostgreSQL
|
// remove the default config properties which don't exist for PostgreSQL
|
||||||
properties.remove("useUnicode");
|
properties.remove("useUnicode");
|
||||||
properties.remove("characterEncoding");
|
properties.remove("characterEncoding");
|
||||||
|
|
||||||
|
// socketTimeout -> networkTimeout
|
||||||
|
Object socketTimeout = properties.remove("socketTimeout");
|
||||||
|
if (socketTimeout != null) {
|
||||||
|
properties.putIfAbsent("networkTimeout", Integer.parseInt(socketTimeout.toString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -61,7 +61,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -60,7 +60,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -29,7 +29,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -42,7 +42,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -27,13 +27,18 @@ dependencies {
|
|||||||
testImplementation 'org.mockito:mockito-core:4.11.0'
|
testImplementation 'org.mockito:mockito-core:4.11.0'
|
||||||
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
|
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
|
||||||
|
|
||||||
|
testImplementation 'com.zaxxer:HikariCP:4.0.3'
|
||||||
|
testImplementation 'redis.clients:jedis:3.5.2'
|
||||||
|
testImplementation 'io.nats:jnats:2.16.4'
|
||||||
|
testImplementation 'com.rabbitmq:amqp-client:5.12.0'
|
||||||
|
testImplementation 'com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9'
|
||||||
testImplementation 'com.h2database:h2:2.1.214'
|
testImplementation 'com.h2database:h2:2.1.214'
|
||||||
testImplementation 'mysql:mysql-connector-java:8.0.23'
|
testImplementation 'mysql:mysql-connector-java:8.0.23'
|
||||||
testImplementation 'org.mariadb.jdbc:mariadb-java-client:2.7.2'
|
testImplementation 'org.mariadb.jdbc:mariadb-java-client:2.7.2'
|
||||||
testImplementation 'org.postgresql:postgresql:42.2.19'
|
|
||||||
testImplementation 'org.mongodb:mongodb-driver-sync:4.5.0'
|
testImplementation 'org.mongodb:mongodb-driver-sync:4.5.0'
|
||||||
testImplementation 'me.lucko.configurate:configurate-toml:3.7'
|
testImplementation 'me.lucko.configurate:configurate-toml:3.7'
|
||||||
testImplementation 'org.spongepowered:configurate-hocon:3.7.2'
|
testImplementation 'org.spongepowered:configurate-hocon:3.7.2'
|
||||||
|
testImplementation 'org.yaml:snakeyaml:1.28'
|
||||||
|
|
||||||
testImplementation project(':standalone:app')
|
testImplementation project(':standalone:app')
|
||||||
testImplementation project(':common:loader-utils')
|
testImplementation project(':common:loader-utils')
|
||||||
@ -54,7 +59,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
@ -51,7 +51,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
@Testcontainers
|
@Testcontainers
|
||||||
@Tag("docker")
|
//@Tag("docker")
|
||||||
public class MessagingIntegrationTest {
|
public class MessagingIntegrationTest {
|
||||||
|
|
||||||
private static void testMessaging(Map<String, String> config, Path tempDirA, Path tempDirB) throws InterruptedException {
|
private static void testMessaging(Map<String, String> config, Path tempDirA, Path tempDirB) throws InterruptedException {
|
||||||
@ -73,7 +73,10 @@ public class MessagingIntegrationTest {
|
|||||||
assertNotNull(messagingServiceB);
|
assertNotNull(messagingServiceB);
|
||||||
|
|
||||||
CountDownLatch latch = new CountDownLatch(1);
|
CountDownLatch latch = new CountDownLatch(1);
|
||||||
pluginB.app().getApi().getEventBus().subscribe(PreNetworkSyncEvent.class, e -> latch.countDown());
|
pluginB.app().getApi().getEventBus().subscribe(PreNetworkSyncEvent.class, e -> {
|
||||||
|
latch.countDown();
|
||||||
|
e.setCancelled(true);
|
||||||
|
});
|
||||||
|
|
||||||
// send a message from plugin A to plugin B and wait for the message to be received
|
// send a message from plugin A to plugin B and wait for the message to be received
|
||||||
messagingServiceA.pushUpdate();
|
messagingServiceA.pushUpdate();
|
||||||
@ -109,6 +112,33 @@ public class MessagingIntegrationTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nested
|
||||||
|
class Postgres {
|
||||||
|
|
||||||
|
@Container
|
||||||
|
private final GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("postgres"))
|
||||||
|
.withEnv("POSTGRES_PASSWORD", "passw0rd")
|
||||||
|
.withExposedPorts(5432);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPostgres(@TempDir Path tempDirA, @TempDir Path tempDirB) throws InterruptedException {
|
||||||
|
assertTrue(this.container.isRunning());
|
||||||
|
|
||||||
|
String host = this.container.getHost();
|
||||||
|
Integer port = this.container.getFirstMappedPort();
|
||||||
|
|
||||||
|
Map<String, String> config = ImmutableMap.<String, String>builder()
|
||||||
|
.put("storage-method", "postgresql")
|
||||||
|
.put("data.address", host + ":" + port)
|
||||||
|
.put("data.database", "postgres")
|
||||||
|
.put("data.username", "postgres")
|
||||||
|
.put("data.password", "passw0rd")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
testMessaging(config, tempDirA, tempDirB);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
class Redis {
|
class Redis {
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ shadowJar {
|
|||||||
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
relocate 'me.lucko.commodore', 'me.lucko.luckperms.lib.commodore'
|
||||||
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
relocate 'org.mariadb.jdbc', 'me.lucko.luckperms.lib.mariadb'
|
||||||
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
relocate 'com.mysql', 'me.lucko.luckperms.lib.mysql'
|
||||||
relocate 'org.postgresql', 'me.lucko.luckperms.lib.postgresql'
|
relocate 'com.impossibl', 'me.lucko.luckperms.lib.postgresql'
|
||||||
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
relocate 'com.zaxxer.hikari', 'me.lucko.luckperms.lib.hikari'
|
||||||
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
relocate 'com.mongodb', 'me.lucko.luckperms.lib.mongodb'
|
||||||
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
relocate 'org.bson', 'me.lucko.luckperms.lib.bson'
|
||||||
|
Loading…
Reference in New Issue
Block a user