starpc 0.33.4 → 0.33.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.33.4",
3
+ "version": "0.33.6",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -105,7 +105,7 @@ func (r *ClientRPC) HandleCallStart(pkt *CallStart) error {
105
105
  // Close releases any resources held by the ClientRPC.
106
106
  func (r *ClientRPC) Close() {
107
107
  if r.writer != nil {
108
- _ = r.WriteCancel()
108
+ _ = r.WriteCallCancel()
109
109
  }
110
110
 
111
111
  r.bcast.HoldLock(func(broadcast func(), getWaitCh func() <-chan struct{}) {
@@ -98,8 +98,12 @@ func (c *commonRPC) ReadOne() ([]byte, error) {
98
98
  waitCh = getWaitCh()
99
99
  })
100
100
 
101
- if hasMsg || err != nil {
102
- return msg, err
101
+ if hasMsg {
102
+ return msg, nil
103
+ }
104
+
105
+ if err != nil {
106
+ return nil, err
103
107
  }
104
108
 
105
109
  select {
@@ -169,8 +173,8 @@ func (c *commonRPC) HandleCallData(pkt *CallData) error {
169
173
  return err
170
174
  }
171
175
 
172
- // WriteCancel writes a call cancel packet.
173
- func (c *commonRPC) WriteCancel() error {
176
+ // WriteCallCancel writes a call cancel packet.
177
+ func (c *commonRPC) WriteCallCancel() error {
174
178
  if c.writer != nil {
175
179
  return c.writer.WritePacket(NewCallCancelPacket())
176
180
  }
@@ -13,6 +13,9 @@ type MsgStreamRw interface {
13
13
 
14
14
  // WriteCallData writes a call data packet.
15
15
  WriteCallData(data []byte, complete bool, err error) error
16
+
17
+ // WriteCallCancel writes a call cancel (close) packet.
18
+ WriteCallCancel() error
16
19
  }
17
20
 
18
21
  // MsgStream implements the stream interface passed to implementations.
@@ -75,12 +78,12 @@ func (r *MsgStream) CloseSend() error {
75
78
 
76
79
  // Close closes the stream.
77
80
  func (r *MsgStream) Close() error {
78
- _ = r.CloseSend()
81
+ err := r.rw.WriteCallCancel()
79
82
  if r.closeCb != nil {
80
83
  r.closeCb()
81
84
  }
82
85
 
83
- return nil
86
+ return err
84
87
  }
85
88
 
86
89
  // _ is a type assertion