@@ -3,7 +3,7 @@ package provisionersdk
3
3
import (
4
4
"context"
5
5
"io"
6
- "sync "
6
+ "net "
7
7
8
8
"github.com/hashicorp/yamux"
9
9
"storj.io/drpc"
@@ -18,22 +18,14 @@ const (
18
18
19
19
// TransportPipe creates an in-memory pipe for dRPC transport.
20
20
func TransportPipe () (* yamux.Session , * yamux.Session ) {
21
- clientReader , clientWriter := io .Pipe ()
22
- serverReader , serverWriter := io .Pipe ()
21
+ c1 , c2 := net .Pipe ()
23
22
yamuxConfig := yamux .DefaultConfig ()
24
23
yamuxConfig .LogOutput = io .Discard
25
- client , err := yamux .Client (& readWriteCloser {
26
- ReadCloser : clientReader ,
27
- WriteCloser : serverWriter ,
28
- }, yamuxConfig )
24
+ client , err := yamux .Client (c1 , yamuxConfig )
29
25
if err != nil {
30
26
panic (err )
31
27
}
32
-
33
- server , err := yamux .Server (& readWriteCloser {
34
- ReadCloser : serverReader ,
35
- WriteCloser : clientWriter ,
36
- }, yamuxConfig )
28
+ server , err := yamux .Server (c2 , yamuxConfig )
37
29
if err != nil {
38
30
panic (err )
39
31
}
@@ -45,22 +37,6 @@ func Conn(session *yamux.Session) drpc.Conn {
45
37
return & multiplexedDRPC {session }
46
38
}
47
39
48
- type readWriteCloser struct {
49
- closeMutex sync.Mutex
50
- io.ReadCloser
51
- io.WriteCloser
52
- }
53
-
54
- func (c * readWriteCloser ) Close () error {
55
- c .closeMutex .Lock ()
56
- defer c .closeMutex .Unlock ()
57
- err := c .ReadCloser .Close ()
58
- if err != nil {
59
- return err
60
- }
61
- return c .WriteCloser .Close ()
62
- }
63
-
64
40
// Allows concurrent requests on a single dRPC connection.
65
41
// Required for calling functions concurrently.
66
42
type multiplexedDRPC struct {
0 commit comments