diff --git a/mino/minogrpc/overlay.go b/mino/minogrpc/overlay.go index df68e1ac0..72a4788bd 100644 --- a/mino/minogrpc/overlay.go +++ b/mino/minogrpc/overlay.go @@ -113,17 +113,17 @@ func (o overlayService) Stream(stream Overlay_StreamServer) error { rpcID := o.addr.String() // Listen on the first message, which should be the routing infos - enveloppe, err := stream.Recv() + envelope, err := stream.Recv() if err != nil { return xerrors.Errorf("failed to receive first routing message: %v", err) } - rting, err := o.routingFactory.FromAny(enveloppe.Message) + rting, err := o.routingFactory.FromAny(envelope.Message) if err != nil { return xerrors.Errorf("failed to decode routing message: %v", err) } - o.rootAddr = address{enveloppe.PhysicalFrom} + o.rootAddr = address{envelope.PhysicalFrom} // fmt.Print(o.addr) // rting.(*routing.TreeRouting).Display(os.Stdout) @@ -135,16 +135,16 @@ func (o overlayService) Stream(stream Overlay_StreamServer) error { encoder: o.encoder, // This address is used when the client doesn't find the address it // should send the message to in the list of participant. In that case - // it packs the message in an enveloppe and send it back to this - // address, which is registered in the list of participant. - // It is also used to indicate the "from" of the message in the case it - // doesn't relay but sends directly. + // it packs the message in an envelope and send it back to this address, + // which is registered in the list of participant. It is also used to + // indicate the "from" of the message in the case it doesn't relay but + // sends directly. address: address{rpcID}, name: "remote RPC of " + o.addr.String(), srvCert: o.srvCert, traffic: o.traffic, routing: rting, - rootAddr: address{enveloppe.PhysicalFrom}, + rootAddr: address{envelope.PhysicalFrom}, } sender.participants.Store(rpcID, stream) @@ -201,7 +201,7 @@ func (o overlayService) Stream(stream Overlay_StreamServer) error { From: o.addr.String(), PhysicalFrom: o.addr.String(), To: []string{addr.String()}, - Message: enveloppe.Message, + Message: envelope.Message, }) // TODO: think how we can make all the node set the routing then start diff --git a/mino/minogrpc/overlay.pb.go b/mino/minogrpc/overlay.pb.go index f854da942..3401217d8 100644 --- a/mino/minogrpc/overlay.pb.go +++ b/mino/minogrpc/overlay.pb.go @@ -28,10 +28,10 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Envelope is wrapper around a message and one or several recipients. type Envelope struct { // This is the origin address of the message. For example if node A sends a - // message to Node C via Node B, then node C will receive an enveloppe with + // message to Node C via Node B, then node C will receive an envelope with // "from = A" and "physicalFrom = B" From string `protobuf:"bytes,1,opt,name=from,proto3" json:"from,omitempty"` - // This is the real address of the node that sent this enveloppe + // This is the real address of the node that sent this envelope PhysicalFrom string `protobuf:"bytes,2,opt,name=physicalFrom,proto3" json:"physicalFrom,omitempty"` To []string `protobuf:"bytes,3,rep,name=to,proto3" json:"to,omitempty"` Message *any.Any `protobuf:"bytes,4,opt,name=message,proto3" json:"message,omitempty"` diff --git a/mino/minogrpc/overlay.proto b/mino/minogrpc/overlay.proto index ef9158aa3..bcbc7616e 100644 --- a/mino/minogrpc/overlay.proto +++ b/mino/minogrpc/overlay.proto @@ -7,10 +7,10 @@ import "google/protobuf/any.proto"; // Envelope is wrapper around a message and one or several recipients. message Envelope { // This is the origin address of the message. For example if node A sends a - // message to Node C via Node B, then node C will receive an enveloppe with + // message to Node C via Node B, then node C will receive an envelope with // "from = A" and "physicalFrom = B" string from = 1; - // This is the real address of the node that sent this enveloppe + // This is the real address of the node that sent this envelope string physicalFrom = 2; repeated string to = 3; google.protobuf.Any message = 4; diff --git a/mino/minogrpc/server.go b/mino/minogrpc/server.go index 22b3400d7..8778e60ee 100644 --- a/mino/minogrpc/server.go +++ b/mino/minogrpc/server.go @@ -283,7 +283,6 @@ func (rpc RPC) Stream(ctx context.Context, func listenStream(stream overlayStream, orchRecv *receiver, orchSender *sender, addr mino.Address) error { - // This msg.Message should always be an enveloppe envelope, err := stream.Recv() if err == io.EOF { return io.EOF @@ -315,7 +314,7 @@ func listenStream(stream overlayStream, orchRecv *receiver, msg, err := orchRecv.encoder.UnmarshalDynamicAny(envelope.Message) if err != nil { - return xerrors.Errorf("failed to unmarshal enveloppe message: %v", err) + return xerrors.Errorf("failed to unmarshal envelope message: %v", err) } errChan := orchSender.sendWithFrom(msg, @@ -593,12 +592,12 @@ type receiver struct { // Recv implements mino.receiver func (r receiver) Recv(ctx context.Context) (mino.Address, proto.Message, error) { // TODO: close the channel - var enveloppe *Envelope + var envelope *Envelope var err error var ok bool select { - case enveloppe, ok = <-r.in: + case envelope, ok = <-r.in: if !ok { return nil, nil, errors.New("time to end") } @@ -612,16 +611,16 @@ func (r receiver) Recv(ctx context.Context) (mino.Address, proto.Message, error) } // we check it to prevent a panic on msg.Message - if enveloppe == nil { + if envelope == nil { return nil, nil, xerrors.New("message is nil") } - msg, err := r.encoder.UnmarshalDynamicAny(enveloppe.Message) + msg, err := r.encoder.UnmarshalDynamicAny(envelope.Message) if err != nil { - return nil, nil, xerrors.Errorf("failed to unmarshal enveloppe msg: %v", err) + return nil, nil, xerrors.Errorf("failed to unmarshal envelope msg: %v", err) } - return address{id: enveloppe.From}, msg, nil + return address{id: envelope.From}, msg, nil } // This interface is used to have a common object between Overlay_StreamServer diff --git a/mino/minogrpc/server_test.go b/mino/minogrpc/server_test.go index 56e1ef385..c922a6080 100644 --- a/mino/minogrpc/server_test.go +++ b/mino/minogrpc/server_test.go @@ -1027,7 +1027,7 @@ func TestReceiver_Recv(t *testing.T) { receiver.encoder = badUnmarshalAnyEncoder{} receiver.in <- msg _, _, err = receiver.Recv(context.Background()) - require.EqualError(t, err, "failed to unmarshal enveloppe msg: message is nil") + require.EqualError(t, err, "failed to unmarshal envelope msg: message is nil") // now with a failing unmarshal of the message msg.Message, err = ptypes.MarshalAny(&Envelope{}) @@ -1035,7 +1035,7 @@ func TestReceiver_Recv(t *testing.T) { receiver.encoder = badUnmarshalDynEncoder{} receiver.in <- msg _, _, err = receiver.Recv(context.Background()) - require.EqualError(t, err, "failed to unmarshal enveloppe msg: oops") + require.EqualError(t, err, "failed to unmarshal envelope msg: oops") } // -----------------------------------------------------------------------------