Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: logdog/client/butlerlib/streamclient/stream.go

Issue 2737603003: Butler stream servers can generate client address. (Closed)
Patch Set: better comment Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « logdog/client/butlerlib/streamclient/local.go ('k') | logdog/client/butlerlib/streamclient/stream_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/client/butlerlib/streamclient/stream.go
diff --git a/logdog/client/butlerlib/streamclient/stream.go b/logdog/client/butlerlib/streamclient/stream.go
index 73c98629546dadbc4df61130cd15c6d3d2c63df2..ede2172940207989943b42f2305ae67cccbc8bb7 100644
--- a/logdog/client/butlerlib/streamclient/stream.go
+++ b/logdog/client/butlerlib/streamclient/stream.go
@@ -25,21 +25,23 @@ type Stream interface {
Properties() *streamproto.Properties
}
-// streamImpl is the standard implementation of the Stream interface.
-type streamImpl struct {
+// BaseStream is the standard implementation of the Stream interface.
+type BaseStream struct {
+ // WriteCloser (required) is the stream's underlying io.WriteCloser.
io.WriteCloser
- // props is this stream's properties.
- props *streamproto.Properties
+ // P (required) is this stream's properties.
+ P *streamproto.Properties
// rioW is a recordio.Writer bound to the WriteCloser. This will be
// initialized on the first writeRecord invocation.
rioW recordio.Writer
}
-var _ Stream = (*streamImpl)(nil)
+var _ Stream = (*BaseStream)(nil)
-func (s *streamImpl) WriteDatagram(dg []byte) error {
+// WriteDatagram implements StreamClient.
+func (s *BaseStream) WriteDatagram(dg []byte) error {
if !s.isDatagramStream() {
return errors.New("not a datagram stream")
}
@@ -47,7 +49,8 @@ func (s *streamImpl) WriteDatagram(dg []byte) error {
return s.writeRecord(dg)
}
-func (s *streamImpl) Write(data []byte) (int, error) {
+// Write implements StreamClient.
+func (s *BaseStream) Write(data []byte) (int, error) {
if s.isDatagramStream() {
return 0, errors.New("cannot use Write with datagram stream")
}
@@ -55,11 +58,11 @@ func (s *streamImpl) Write(data []byte) (int, error) {
return s.writeRaw(data)
}
-func (s *streamImpl) writeRaw(data []byte) (int, error) {
+func (s *BaseStream) writeRaw(data []byte) (int, error) {
return s.WriteCloser.Write(data)
}
-func (s *streamImpl) writeRecord(r []byte) error {
+func (s *BaseStream) writeRecord(r []byte) error {
if s.rioW == nil {
s.rioW = recordio.NewWriter(s.WriteCloser)
}
@@ -69,8 +72,9 @@ func (s *streamImpl) writeRecord(r []byte) error {
return s.rioW.Flush()
}
-func (s *streamImpl) isDatagramStream() bool {
- return s.props.StreamType == logpb.StreamType_DATAGRAM
+func (s *BaseStream) isDatagramStream() bool {
+ return s.P.StreamType == logpb.StreamType_DATAGRAM
}
-func (s *streamImpl) Properties() *streamproto.Properties { return s.props.Clone() }
+// Properties implements StreamClient.
+func (s *BaseStream) Properties() *streamproto.Properties { return s.P.Clone() }
« no previous file with comments | « logdog/client/butlerlib/streamclient/local.go ('k') | logdog/client/butlerlib/streamclient/stream_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698