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();
}
Aggregations