Method
Dial
(ctx context.Context, a Addr)
Source from the content-addressed store, hash-verified
| 59 | } |
| 60 | |
| 61 | func (n *InProcNet) Dial(ctx context.Context, a Addr) (net.Conn, error) { |
| 62 | n.Lock() |
| 63 | defer n.Unlock() |
| 64 | l, ok := n.listeners[a] |
| 65 | if !ok { |
| 66 | return nil, xerrors.Errorf("nothing listening on %s", a) |
| 67 | } |
| 68 | x, y := net.Pipe() |
| 69 | select { |
| 70 | case <-ctx.Done(): |
| 71 | return nil, ctx.Err() |
| 72 | case l.c <- x: |
| 73 | return y, nil |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | func newInProcListener(n *InProcNet, a Addr) *inProcListener { |
| 78 | return &inProcListener{ |