1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

send client error if it exists

This commit is contained in:
Asim Aslam 2019-08-15 15:22:53 +01:00
parent b776fbb766
commit f6b8045dd5
2 changed files with 17 additions and 0 deletions

View File

@ -126,6 +126,7 @@ func setHeaders(m *codec.Message) {
set("Micro-Service", m.Target)
set("Micro-Method", m.Method)
set("Micro-Endpoint", m.Endpoint)
set("Micro-Error", m.Error)
}
// setupProtocol sets up the old protocol

View File

@ -2,6 +2,8 @@ package server
import (
"context"
"errors"
"io"
"sync"
"github.com/micro/go-micro/codec"
@ -59,6 +61,20 @@ func (r *rpcStream) Recv(msg interface{}) error {
return err
}
// check the error
if len(req.Error) > 0 {
// Check the client closed the stream
switch req.Error {
case lastStreamResponseError.Error():
// discard body
r.codec.ReadBody(nil)
r.err = io.EOF
return io.EOF
default:
return errors.New(req.Error)
}
}
// we need to stay up to date with sequence numbers
r.id = req.Id
if err := r.codec.ReadBody(msg); err != nil {