-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Rewrite serialization #61
Conversation
* basic JsonSerializer, replacing JsonMessageCodec
@@ -200,6 +203,97 @@ private[akka] object AnySupport { | |||
} | |||
|
|||
def extractBytes(bytes: ByteString): ByteString = bytesToPrimitive(BytesPrimitive, bytes) | |||
|
|||
def toScalaPbAny(bytesPayload: BytesPayload): ScalaPbAny = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need this for the commands that come from the fixed component endpoint (grpc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, if that's the case, we are receiving BytesPayload
from outside and making a PbAny
.
I think the flow is as follow:
- static endpoint receives json
- http grpc transcoding makes of
PbAny
in the runtime - payload is added to
EntityCommand
- inside ESE in runtime, payload is converted to
BytesPayload
and SPI is called
Then, we will always receive BytesPayload, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, we receive BytesPayload, but with proto contentType so it's not handled by JsonSerializer
these BytesPayload<->PbAny conversions are temporary
* Parse the bytes to object of type corresponding to the type name in the `bytesPayload.contentType`. Requires that | ||
* the types are known by first `registerTypeHints` or calling `contentTypeFor` or `toBytes`. | ||
*/ | ||
def fromBytes(bytesPayload: BytesPayload): AnyRef = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the case where the StrictJsonMessageCodec was used. The event types are registered up front and can then be deserialized without the expectedType: Class[T]
|
||
} | ||
|
||
class JsonSerializer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will probably support other formats, such as proto. I haven't designed for that yet. Wanted to keep it as simple as possible first.
private def _setCurrentState(state: S): Unit = { | ||
def handleEvent(event: E): S = { | ||
event match { | ||
// FIXME can it be proto? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. Now this is always the non-serialized event java type.
@@ -200,6 +203,97 @@ private[akka] object AnySupport { | |||
} | |||
|
|||
def extractBytes(bytes: ByteString): ByteString = bytesToPrimitive(BytesPrimitive, bytes) | |||
|
|||
def toScalaPbAny(bytesPayload: BytesPayload): ScalaPbAny = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, if that's the case, we are receiving BytesPayload
from outside and making a PbAny
.
I think the flow is as follow:
- static endpoint receives json
- http grpc transcoding makes of
PbAny
in the runtime - payload is added to
EntityCommand
- inside ESE in runtime, payload is converted to
BytesPayload
and SPI is called
Then, we will always receive BytesPayload, no?
value = encodeByteArray(ByteStringUtils.toProtoByteStringUnsafe(bytesPayload.bytes))) | ||
} | ||
|
||
private def encodeByteArray(bytes: ByteString): ByteString = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little confusing. I know this code comes from the runtime. Should we assume that is temporary? Because I was expecting the SDK to only know what a BytesPayload
is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyway, so suggestions/questions about this method and it's usage just above.
Better if toProtoByteStringUnsafe
is responsible for adding the proto tag.
Or this encodeByteArray
should be called addProtoTag
or something like that.
Failing tests from local run:
Well merge anyway so that we can work in parallel on the different parts. |
No description provided.