Skip to content

Commit

Permalink
Expose stream protocol method to close Writer
Browse files Browse the repository at this point in the history
  • Loading branch information
dianale31 committed Jun 28, 2021
1 parent 8405012 commit 44d42e0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions gen/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func BenchmarkRoundTrip(b *testing.B) {
give, ok := bb.give.(streamingThriftType)
require.True(b, ok)
require.NoError(b, give.Encode(writer), "StreamEncode")
writer.Close()
}
}

Expand Down
6 changes: 6 additions & 0 deletions protocol/binary/stream_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,9 @@ func (sw *StreamWriter) WriteMapBegin(m stream.MapHeader) error {
func (sw *StreamWriter) WriteMapEnd() error {
return nil
}

// Close frees up the resources used by the StreamWriter and returns it back
// to the pool.
func (sw *StreamWriter) Close() {
ReturnStreamWriter(sw)
}
1 change: 1 addition & 0 deletions protocol/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ type Writer interface {
WriteSetEnd() error
WriteListBegin(l ListHeader) error
WriteListEnd() error
Close()
}

// Reader defines an decoder for a Thrift value, implemented in a streaming
Expand Down

0 comments on commit 44d42e0

Please sign in to comment.