class ZlibCompress implements Compress {

    @Override
    public ByteBuf compressInput(Object proto, RpcMethodInfo rpcMethodInfo) throws IOException {
        int protoSize = rpcMethodInfo.getInputSerializedSize(proto);
        ByteBuf resBuf = Unpooled.buffer(protoSize);
        OutputStream outputStream = new ByteBufOutputStream(resBuf);
        outputStream = new DeflaterOutputStream(outputStream);
        CodedOutputStream codedOutputStream = CodedOutputStream.newInstance(outputStream, protoSize);
        rpcMethodInfo.inputWriteToStream(proto, codedOutputStream);
        outputStream.close();
        return resBuf;
    }

}