akka/akka-core

Missing ability to convert akka.protobuf.ByteString into akka.util.ByteString

开放

#18,738 创建于 2015年10月19日

 (5 条评论) (1 个反应) (0 位负责人)Scala (3,547 个派生)batch import
1 - triagedhelp wantedt:coret:persistence

仓库指标

星标
 (13,277 个星标)
PR 合并指标
 (平均合并 8天 19小时) (30 天内合并 10 个 PR)

描述

We're implementing an akka persistence query plugin. It needs to look inside stored events that are serialized using akka's built-in serialization, in this case the protobuf representation of akka.persistence.serialization.MessageFormats.PersistentMessage. For ease of use, we're re-using that class to unmarshal the persistent events.

PersistentMessage.payload is an instance of akka.protobuf.ByteString, which contains the serialized event itself. The contents depends on how the user has configured akka-serialization: it might be java serialization, a custom probuf version, or something else entirely.

One of the use cases of our plugin is to allow remote views for events. To that end, we actually want to expose the contents of the events directly. Hence, we don't need to read the contents; we just want to serve it up to HTTP (as chunks).

However, akka-http expects akka.util.ByteString, not akka.protobuf.ByteString. Even worse is that with current APIs, it's not possible to convert one into the other without copying the bytes. It would be very convenient to be allowed to coerce protobuf.ByteString into util.ByteString, while re-using the underlying byte array / byte buffer.

贡献者指南