com.github.lontime.extredisson.notify.NotifyProvider Maven / Gradle / Ivy
The newest version!
package com.github.lontime.extredisson.notify;
import com.github.lontime.base.logging.GLogger;
import com.github.lontime.base.serial.GenericObjectSerializers;
import com.github.lontime.base.serial.MsgpackSerial;
import com.github.lontime.shaded.com.twitter.serial.serializer.Serializer;
/**
* NotifyProvider.
* @author lontime
* @since 1.0
*/
public interface NotifyProvider extends AutoCloseable {
/**
* getName.
*
* @return String
*/
String getName();
/**
* close.
*/
@Override
default void close() {
GLogger.defaults().warn(getClass(), "close");
}
/**
* notifyForObject.
*
* @param replyTo replyTos
* @param request request
* @return true/false
*/
default boolean notifyForObject(String replyTo, Object request) {
return notifyForObject(null, replyTo, request);
}
/**
* notifyForObject.
*
* @param replyTo replyTos
* @param request request
* @param connection connection
* @return true/false
*/
default boolean notifyForObject(String connection, String replyTo, Object request) {
return notifyForGeneric(connection, replyTo, request, GenericObjectSerializers.INSTANCE.getObjectSerializer());
}
/**
* notifyForGeneric.
*
* @param replyTo replyTos
* @param request request
* @param serializer serializer
* @param REQ
* @return true/false
*/
default boolean notifyForGeneric(String replyTo, REQ request, Serializer serializer) {
return notifyForGeneric(null, replyTo, request, serializer);
}
/**
* notifyForGeneric.
*
* @param connection connection
* @param replyTo replyTos
* @param request request
* @param serializer serializer
* @param REQ
* @return true/false
*/
default boolean notifyForGeneric(String connection, String replyTo, REQ request, Serializer serializer) {
final byte[] bytes = MsgpackSerial.INSTANCE.toByteArrayUnchecked(request, serializer);
return notify(connection, replyTo, bytes);
}
/**
* notifyForGeneric.
*
* @param replyTo replyTos
* @param bytes bytes
* @return true/false
*/
default boolean notify(String replyTo, byte[] bytes) {
return notify(null, replyTo, bytes);
}
/**
* notifyForGeneric.
*
* @param connection connection
* @param replyTo replyTos
* @param bytes bytes
* @return true/false
*/
boolean notify(String connection, String replyTo, byte[] bytes);
}