send client error if it exists
This commit is contained in:
parent
b776fbb766
commit
f6b8045dd5
@ -126,6 +126,7 @@ func setHeaders(m *codec.Message) {
|
|||||||
set("Micro-Service", m.Target)
|
set("Micro-Service", m.Target)
|
||||||
set("Micro-Method", m.Method)
|
set("Micro-Method", m.Method)
|
||||||
set("Micro-Endpoint", m.Endpoint)
|
set("Micro-Endpoint", m.Endpoint)
|
||||||
|
set("Micro-Error", m.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setupProtocol sets up the old protocol
|
// setupProtocol sets up the old protocol
|
||||||
|
@ -2,6 +2,8 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/micro/go-micro/codec"
|
"github.com/micro/go-micro/codec"
|
||||||
@ -59,6 +61,20 @@ func (r *rpcStream) Recv(msg interface{}) error {
|
|||||||
return err
|
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
|
// we need to stay up to date with sequence numbers
|
||||||
r.id = req.Id
|
r.id = req.Id
|
||||||
if err := r.codec.ReadBody(msg); err != nil {
|
if err := r.codec.ReadBody(msg); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user