split wrap into wrap / unwrap types

This commit is contained in:
William Banfield
2022-10-20 16:50:57 -04:00
parent 61834bb5fc
commit 27db33dbda
2 changed files with 7 additions and 5 deletions

View File

@@ -420,7 +420,7 @@ func createMConnection(
"peer_id", string(p.ID()),
"chID", fmt.Sprintf("%#x", chID),
}
if w, ok := msg.(Wrapper); ok {
if w, ok := msg.(Unwrapper); ok {
msg, err = w.Unwrap()
if err != nil {
// TODO(williambanfield) add error log line.

View File

@@ -19,12 +19,14 @@ type Envelope struct {
// (e.g. via oneof fields). If a Channel's message type implements Wrapper, the
// Router will automatically wrap outbound messages and unwrap inbound messages,
// such that reactors do not have to do this themselves.
type Wrapper interface {
type Unwrapper interface {
proto.Message
// Wrap will take a message and wrap it in this one if possible.
Wrap(proto.Message) error
// Unwrap will unwrap the inner message contained in this message.
Unwrap() (proto.Message, error)
}
type Wrapper interface {
// Wrap will take the underlying message and wrap it in its wrapper type.
Wrap() (proto.Message, error)
}