Class WireCodec
Commands and queries travel over different endpoints with different shapes, but a failure is described the same way in both. Keeping that here means the two directions cannot drift apart into encodings that no longer read each other.
Marked Internal because it is public only so that the command and query converters, which live in separate
packages, can share it. It is not meant to be used outside this module.
- Since:
- 5.4.0
- Author:
- Allard Buijze
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte @Nullable []convertedDetailsOf(Throwable cause, @Nullable Converter converter) Returns the application-specific details the givencausecarries, as the bytes to write.static byte @Nullable []Decodes whatencode(byte[])wrote.descriptionsOf(Throwable cause) Describes the givencauseand the causes behind it, outermost first.static @Nullable Stringencode(byte @Nullable [] bytes) Encodes the givenbytesfor transport, asnullwhen there is nothing to carry.static StringDescribes the givencause, falling back to its type when it carries no message.
-
Method Details
-
encode
Encodes the givenbytesfor transport, asnullwhen there is nothing to carry.- Parameters:
bytes- the bytes to encode- Returns:
- the encoded form of the given
bytes, ornullwhen there are none
-
decode
Decodes whatencode(byte[])wrote.- Parameters:
encoded- the encoded bytes, ornullwhen none were carried- Returns:
- the bytes the given
encodedform represents, ornullwhen it isnull
-
messageOf
Describes the givencause, falling back to its type when it carries no message.- Parameters:
cause- the failure to describe- Returns:
- a description of the given
cause
-
descriptionsOf
Describes the givencauseand the causes behind it, outermost first.The chain is followed to a bounded depth, so that a cycle or a pathologically deep chain cannot turn a failure into an unbounded reply.
- Parameters:
cause- the failure to describe- Returns:
- descriptions of the given
causeand the causes behind it
-
convertedDetailsOf
Returns the application-specific details the givencausecarries, as the bytes to write.Details that cannot be converted are omitted rather than raised: a failure that cannot be described in full is still worth reporting, and replacing it with a conversion failure would hide what actually went wrong.
- Parameters:
cause- the failure whose details to writeconverter- the converter to write the details with, ornullwhen none is available- Returns:
- the bytes to write for the given
cause's details, ornullwhen it carries none that can be written
-