starpc 0.26.2 → 0.27.1
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/echo/echo.go +8 -8
- package/go.mod +2 -2
- package/go.sum +4 -4
- package/package.json +1 -1
- package/srpc/stream.go +28 -4
package/echo/echo.go
CHANGED
|
@@ -7,15 +7,15 @@ import (
|
|
|
7
7
|
|
|
8
8
|
// _ is a type assertion
|
|
9
9
|
var (
|
|
10
|
-
_ srpc.StreamRecv[EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
11
|
-
_ srpc.StreamRecv[EchoMsg] = (SRPCEchoer_EchoServerStreamClient)(nil)
|
|
10
|
+
_ srpc.StreamRecv[*EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
11
|
+
_ srpc.StreamRecv[*EchoMsg] = (SRPCEchoer_EchoServerStreamClient)(nil)
|
|
12
12
|
|
|
13
|
-
_ srpc.StreamSend[EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
14
|
-
_ srpc.StreamSend[EchoMsg] = (SRPCEchoer_EchoClientStreamClient)(nil)
|
|
13
|
+
_ srpc.StreamSend[*EchoMsg] = (SRPCEchoer_EchoBidiStreamClient)(nil)
|
|
14
|
+
_ srpc.StreamSend[*EchoMsg] = (SRPCEchoer_EchoClientStreamClient)(nil)
|
|
15
15
|
|
|
16
|
-
_ srpc.StreamSendAndClose[EchoMsg] = (SRPCEchoer_EchoBidiStreamStream)(nil)
|
|
17
|
-
_ srpc.StreamSendAndClose[EchoMsg] = (SRPCEchoer_EchoServerStreamStream)(nil)
|
|
16
|
+
_ srpc.StreamSendAndClose[*EchoMsg] = (SRPCEchoer_EchoBidiStreamStream)(nil)
|
|
17
|
+
_ srpc.StreamSendAndClose[*EchoMsg] = (SRPCEchoer_EchoServerStreamStream)(nil)
|
|
18
18
|
|
|
19
|
-
_ srpc.StreamRecv[rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
20
|
-
_ srpc.StreamSendAndClose[rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
19
|
+
_ srpc.StreamRecv[*rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
20
|
+
_ srpc.StreamSendAndClose[*rpcstream.RpcStreamPacket] = (SRPCEchoer_RpcStreamStream)(nil)
|
|
21
21
|
)
|
package/go.mod
CHANGED
|
@@ -9,7 +9,7 @@ require (
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
|
-
github.com/aperturerobotics/util v1.
|
|
12
|
+
github.com/aperturerobotics/util v1.14.2 // latest
|
|
13
13
|
github.com/libp2p/go-libp2p v0.33.0 // latest
|
|
14
14
|
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240206065824-7222fbc3459d // master
|
|
15
15
|
github.com/sirupsen/logrus v1.9.3 // latest
|
|
@@ -34,7 +34,7 @@ require (
|
|
|
34
34
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
|
35
35
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
36
36
|
golang.org/x/crypto v0.19.0 // indirect
|
|
37
|
-
golang.org/x/exp v0.0.0-
|
|
37
|
+
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 // indirect
|
|
38
38
|
golang.org/x/sys v0.17.0 // indirect
|
|
39
39
|
lukechampine.com/blake3 v1.2.1 // indirect
|
|
40
40
|
)
|
package/go.sum
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
github.com/aperturerobotics/util v1.
|
|
2
|
-
github.com/aperturerobotics/util v1.
|
|
1
|
+
github.com/aperturerobotics/util v1.14.2 h1:AghqzGgZoufsdQstY6cCssHHMB/uCv8+BjysAE55S98=
|
|
2
|
+
github.com/aperturerobotics/util v1.14.2/go.mod h1:1+G2THhT7VCmR7xeRlqDnyEtRFvONWoPft19xTHvbyk=
|
|
3
3
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
4
4
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
5
5
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
@@ -57,8 +57,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|
|
57
57
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
58
58
|
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
|
59
59
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
|
60
|
-
golang.org/x/exp v0.0.0-
|
|
61
|
-
golang.org/x/exp v0.0.0-
|
|
60
|
+
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ=
|
|
61
|
+
golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc=
|
|
62
62
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
63
63
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
64
64
|
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
package/package.json
CHANGED
package/srpc/stream.go
CHANGED
|
@@ -28,8 +28,8 @@ type Stream interface {
|
|
|
28
28
|
// T is the response type.
|
|
29
29
|
type StreamRecv[T any] interface {
|
|
30
30
|
Stream
|
|
31
|
-
Recv() (
|
|
32
|
-
RecvTo(
|
|
31
|
+
Recv() (T, error)
|
|
32
|
+
RecvTo(T) error
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// StreamSend is a stream that can send typed messages.
|
|
@@ -37,7 +37,7 @@ type StreamRecv[T any] interface {
|
|
|
37
37
|
// T is the outgoing type.
|
|
38
38
|
type StreamSend[T any] interface {
|
|
39
39
|
Stream
|
|
40
|
-
Send(
|
|
40
|
+
Send(T) error
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// StreamSendAndClose is a stream that can send typed messages, closing after.
|
|
@@ -45,5 +45,29 @@ type StreamSend[T any] interface {
|
|
|
45
45
|
// T is the outgoing type.
|
|
46
46
|
type StreamSendAndClose[T any] interface {
|
|
47
47
|
StreamSend[T]
|
|
48
|
-
SendAndClose(
|
|
48
|
+
SendAndClose(T) error
|
|
49
49
|
}
|
|
50
|
+
|
|
51
|
+
// streamWithClose is a Stream with a wrapped Close function.
|
|
52
|
+
type streamWithClose struct {
|
|
53
|
+
Stream
|
|
54
|
+
closeFn func() error
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// NewStreamWithClose wraps a Stream with a close function to call when Close is called.
|
|
58
|
+
func NewStreamWithClose(strm Stream, close func() error) Stream {
|
|
59
|
+
return &streamWithClose{Stream: strm, closeFn: close}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Close closes the stream for reading and writing.
|
|
63
|
+
func (s *streamWithClose) Close() error {
|
|
64
|
+
err := s.Stream.Close()
|
|
65
|
+
err2 := s.closeFn()
|
|
66
|
+
if err != nil {
|
|
67
|
+
return err
|
|
68
|
+
}
|
|
69
|
+
return err2
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// _ is a type assertion
|
|
73
|
+
var _ Stream = (*streamWithClose)(nil)
|