Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Commit

Permalink
change OpenStream to accept a context
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Dec 17, 2020
1 parent 3123af3 commit ba56ac2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func (c *conn) IsClosed() bool {
}

// OpenStream creates a new stream.
func (c *conn) OpenStream() (mux.MuxedStream, error) {
qstr, err := c.sess.OpenStreamSync(context.Background())
func (c *conn) OpenStream(ctx context.Context) (mux.MuxedStream, error) {
qstr, err := c.sess.OpenStreamSync(ctx)
return &stream{Stream: qstr}, err
}

Expand Down
6 changes: 3 additions & 3 deletions conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ var _ = Describe("Connection", func() {
Expect(err).ToNot(HaveOccurred())
defer serverConn.Close()

str, err := conn.OpenStream()
str, err := conn.OpenStream(context.Background())
Expect(err).ToNot(HaveOccurred())
_, err = str.Write([]byte("foobar"))
Expect(err).ToNot(HaveOccurred())
Expand Down Expand Up @@ -251,7 +251,7 @@ var _ = Describe("Connection", func() {
for _, c := range []tpt.CapableConn{serverConn1, serverConn2} {
go func(conn tpt.CapableConn) {
defer GinkgoRecover()
str, err := conn.OpenStream()
str, err := conn.OpenStream(context.Background())
Expect(err).ToNot(HaveOccurred())
defer str.Close()
_, err = str.Write(data)
Expand Down Expand Up @@ -315,7 +315,7 @@ var _ = Describe("Connection", func() {
defer GinkgoRecover()
conn, err := ln.Accept()
Expect(err).ToNot(HaveOccurred())
str, err := conn.OpenStream()
str, err := conn.OpenStream(context.Background())
Expect(err).ToNot(HaveOccurred())
str.Write([]byte("foobar"))
}()
Expand Down

0 comments on commit ba56ac2

Please sign in to comment.