Skip to content

Commit

Permalink
Merge pull request #52 from restatedev/issue-51
Browse files Browse the repository at this point in the history
Add comment about deterministic marshaling
  • Loading branch information
jackkleeman authored Feb 10, 2025
2 parents 9166ce4 + 6fc5d31 commit 1df62ed
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ func OutputPayloadFor(codec PayloadCodec, o any) *OutputPayload {
}

// RestateMarshaler can be implemented by types that want to control their own marshaling
// Marshaling *must* be deterministic
type RestateMarshaler interface {
RestateMarshal(codec Codec) ([]byte, error)
OutputPayload(codec Codec) *OutputPayload
}

// Codec is a mechanism for serialising and deserialising a wide range of types.
// Care should be taken to ensure that only valid types are passed to a codec, eg proto.Message for [ProtoCodec].
// Codecs *must* marshal deterministically, such that a round trip of []byte -> any -> []byte leaves the bytes unchanged.
type Codec interface {
Marshal(v any) ([]byte, error)
Unmarshal(data []byte, v any) error
Expand Down

0 comments on commit 1df62ed

Please sign in to comment.