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

functioning proxy code

This commit is contained in:
Asim Aslam
2019-08-16 16:46:29 +01:00
parent 991142cd57
commit 0b0eee41d0
4 changed files with 65 additions and 22 deletions

View File

@ -20,7 +20,10 @@ type rpcStream struct {
context context.Context
// signal whether we should send EOS
eos bool
sendEOS bool
// release releases the connection back to the pool
release func(err error)
}
func (r *rpcStream) isClosed() bool {
@ -125,7 +128,7 @@ func (r *rpcStream) Close() error {
close(r.closed)
// send the end of stream message
if r.eos {
if r.sendEOS {
// no need to check for error
r.codec.Write(&codec.Message{
Id: r.id,
@ -137,6 +140,12 @@ func (r *rpcStream) Close() error {
}, nil)
}
return r.codec.Close()
err := r.codec.Close()
// release the connection
r.release(r.Error())
// return the codec error
return err
}
}