Skip to content

Commit

Permalink
Add bufcon.DialContext(context.Context,string)
Browse files Browse the repository at this point in the history
for use with grpc.WithContextDial DialOption

Signed-off-by: Ed Warnicke <hagbard@gmail.com>
  • Loading branch information
edwarnicke committed Sep 13, 2021
1 parent 5bfc05f commit acf1921
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/bufconn/bufconn.go
Expand Up @@ -21,6 +21,7 @@
package bufconn

import (
"context"
"fmt"
"io"
"net"
Expand Down Expand Up @@ -95,6 +96,16 @@ func (l *Listener) Dial() (net.Conn, error) {
}
}

// DialContext provides a function usable with the grpc.WithContextDial DialOption
func (l *Listener) DialContext(ctx context.Context, _ string) (net.Conn, error) {
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
}
return l.Dial()
}

type pipe struct {
mu sync.Mutex

Expand Down

0 comments on commit acf1921

Please sign in to comment.