@UnstableApi public class RedisEncoder extends MessageToMessageEncoder<RedisMessage>
RedisMessage
into bytes following
RESP (REdis Serialization Protocol).ChannelHandler.Sharable
Modifier and Type | Field and Description |
---|---|
private RedisMessagePool |
messagePool |
Constructor and Description |
---|
RedisEncoder()
Creates a new instance with default
messagePool . |
RedisEncoder(RedisMessagePool messagePool)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected void |
encode(ChannelHandlerContext ctx,
RedisMessage msg,
java.util.List<java.lang.Object> out)
Encode from one message to an other.
|
private byte[] |
numberToBytes(long value) |
private void |
writeArrayHeader(ByteBufAllocator allocator,
ArrayHeaderRedisMessage msg,
java.util.List<java.lang.Object> out)
Write array header only without body.
|
private void |
writeArrayHeader(ByteBufAllocator allocator,
boolean isNull,
long length,
java.util.List<java.lang.Object> out) |
private void |
writeArrayMessage(ByteBufAllocator allocator,
ArrayRedisMessage msg,
java.util.List<java.lang.Object> out)
Write full constructed array message.
|
private static void |
writeBulkStringContent(ByteBufAllocator allocator,
BulkStringRedisContent msg,
java.util.List<java.lang.Object> out) |
private void |
writeBulkStringHeader(ByteBufAllocator allocator,
BulkStringHeaderRedisMessage msg,
java.util.List<java.lang.Object> out) |
private static void |
writeErrorMessage(ByteBufAllocator allocator,
ErrorRedisMessage msg,
java.util.List<java.lang.Object> out) |
private void |
writeFullBulkStringMessage(ByteBufAllocator allocator,
FullBulkStringRedisMessage msg,
java.util.List<java.lang.Object> out) |
private void |
writeIntegerMessage(ByteBufAllocator allocator,
IntegerRedisMessage msg,
java.util.List<java.lang.Object> out) |
private void |
writeRedisMessage(ByteBufAllocator allocator,
RedisMessage msg,
java.util.List<java.lang.Object> out) |
private static void |
writeSimpleStringMessage(ByteBufAllocator allocator,
SimpleStringRedisMessage msg,
java.util.List<java.lang.Object> out) |
private static void |
writeString(ByteBufAllocator allocator,
byte type,
java.lang.String content,
java.util.List<java.lang.Object> out) |
acceptOutboundMessage, write
bind, close, connect, deregister, disconnect, flush, read
ensureNotSharable, exceptionCaught, handlerAdded, handlerRemoved, isSharable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
exceptionCaught, handlerAdded, handlerRemoved
private final RedisMessagePool messagePool
public RedisEncoder()
messagePool
.public RedisEncoder(RedisMessagePool messagePool)
messagePool
- the predefined message pool.protected void encode(ChannelHandlerContext ctx, RedisMessage msg, java.util.List<java.lang.Object> out) throws java.lang.Exception
MessageToMessageEncoder
encode
in class MessageToMessageEncoder<RedisMessage>
ctx
- the ChannelHandlerContext
which this MessageToMessageEncoder
belongs tomsg
- the message to encode to an other oneout
- the List
into which the encoded msg should be added
needs to do some kind of aggregationjava.lang.Exception
- is thrown if an error occursprivate void writeRedisMessage(ByteBufAllocator allocator, RedisMessage msg, java.util.List<java.lang.Object> out)
private static void writeSimpleStringMessage(ByteBufAllocator allocator, SimpleStringRedisMessage msg, java.util.List<java.lang.Object> out)
private static void writeErrorMessage(ByteBufAllocator allocator, ErrorRedisMessage msg, java.util.List<java.lang.Object> out)
private static void writeString(ByteBufAllocator allocator, byte type, java.lang.String content, java.util.List<java.lang.Object> out)
private void writeIntegerMessage(ByteBufAllocator allocator, IntegerRedisMessage msg, java.util.List<java.lang.Object> out)
private void writeBulkStringHeader(ByteBufAllocator allocator, BulkStringHeaderRedisMessage msg, java.util.List<java.lang.Object> out)
private static void writeBulkStringContent(ByteBufAllocator allocator, BulkStringRedisContent msg, java.util.List<java.lang.Object> out)
private void writeFullBulkStringMessage(ByteBufAllocator allocator, FullBulkStringRedisMessage msg, java.util.List<java.lang.Object> out)
private void writeArrayHeader(ByteBufAllocator allocator, ArrayHeaderRedisMessage msg, java.util.List<java.lang.Object> out)
private void writeArrayMessage(ByteBufAllocator allocator, ArrayRedisMessage msg, java.util.List<java.lang.Object> out)
private void writeArrayHeader(ByteBufAllocator allocator, boolean isNull, long length, java.util.List<java.lang.Object> out)
private byte[] numberToBytes(long value)