Search in sources :

Example 1 with HeaderValue

use of io.projectriff.grpc.function.FunctionProtos.Message.HeaderValue in project java-function-invoker by projectriff.

the class MessageConversionUtils method fromGrpc.

public static Message<byte[]> fromGrpc(io.projectriff.grpc.function.FunctionProtos.Message input) {
    MessageBuilder<byte[]> builder = MessageBuilder.withPayload(input.getPayload().toByteArray());
    for (Entry<String, HeaderValue> entry : input.getHeadersMap().entrySet()) {
        HeaderValue header = entry.getValue();
        if (header.getValuesCount() > 0) {
            Object value;
            ProtocolStringList list = header.getValuesList();
            if (list.size() == 1) {
                value = list.get(0);
            } else {
                value = list;
            }
            builder.setHeader(entry.getKey(), value);
        }
    }
    return builder.build();
}
Also used : HeaderValue(io.projectriff.grpc.function.FunctionProtos.Message.HeaderValue) ByteString(com.google.protobuf.ByteString) ProtocolStringList(com.google.protobuf.ProtocolStringList)

Aggregations

ByteString (com.google.protobuf.ByteString)1 ProtocolStringList (com.google.protobuf.ProtocolStringList)1 HeaderValue (io.projectriff.grpc.function.FunctionProtos.Message.HeaderValue)1