1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-12 22:07:47 +02:00

multiplexing cruft

This commit is contained in:
Asim Aslam
2019-08-15 20:08:49 +01:00
parent f6b8045dd5
commit ef04331b86
6 changed files with 209 additions and 66 deletions

View File

@ -18,6 +18,9 @@ type rpcStream struct {
response Response
codec codec.Codec
context context.Context
// signal whether we should send EOS
eos bool
}
func (r *rpcStream) isClosed() bool {
@ -120,6 +123,20 @@ func (r *rpcStream) Close() error {
return nil
default:
close(r.closed)
// send the end of stream message
if r.eos {
// no need to check for error
r.codec.Write(&codec.Message{
Id: r.id,
Target: r.request.Service(),
Method: r.request.Method(),
Endpoint: r.request.Endpoint(),
Type: codec.Error,
Error: lastStreamResponseError,
}, nil)
}
return r.codec.Close()
}
}