We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f2b59a0 commit b36b881Copy full SHA for b36b881
srpc/stream.go
@@ -69,5 +69,24 @@ func (s *streamWithClose) Close() error {
69
return err2
70
}
71
72
+// streamWithContext is a Stream with a wrapped Context function.
73
+type streamWithContext struct {
74
+ Stream
75
+ ctx context.Context
76
+}
77
+
78
+// NewStreamWithContext wraps a Stream with a different context.
79
+func NewStreamWithContext(strm Stream, ctx context.Context) Stream {
80
+ return &streamWithContext{Stream: strm, ctx: ctx}
81
82
83
+// Context returns the stream context.
84
+func (s *streamWithContext) Context() context.Context {
85
+ return s.ctx
86
87
88
// _ is a type assertion
-var _ Stream = (*streamWithClose)(nil)
89
+var (
90
+ _ Stream = (*streamWithClose)(nil)
91
+ _ Stream = (*streamWithContext)(nil)
92
+)
0 commit comments