Skip to content

Commit

Permalink
streaming: Unembed iface.Private in streaming-based interfaces (#533)
Browse files Browse the repository at this point in the history
`iface.Private` was embedded in the newly defined interfaces for streaming to
prevent others from implementing them incase they needed to be modified.

Since the all of the development for streaming has occurred outside of 'dev',
and since it's unlikely for these interfaces to be merged to 'dev' without
already certifying and agreeing on them, unembed these to simplify mocking uses
and to clear out extra code.
  • Loading branch information
witriew authored Aug 14, 2021
1 parent 0a75d8c commit f40a16c
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 101 deletions.
47 changes: 0 additions & 47 deletions internal/iface/iface.go

This file was deleted.

5 changes: 1 addition & 4 deletions protocol/binary/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"fmt"
"io"

"go.uber.org/thriftrw/internal/iface"
"go.uber.org/thriftrw/protocol/envelope"
"go.uber.org/thriftrw/protocol/stream"
"go.uber.org/thriftrw/wire"
Expand All @@ -36,9 +35,7 @@ import (
var Default = new(Protocol)

// Protocol implements the Thrift Binary Protocol.
type Protocol struct {
iface.Private
}
type Protocol struct{}

var _ stream.Protocol = (*Protocol)(nil)
var _ stream.RequestReader = (*Protocol)(nil)
Expand Down
3 changes: 0 additions & 3 deletions protocol/binary/stream_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"math"
"sync"

"go.uber.org/thriftrw/internal/iface"
"go.uber.org/thriftrw/protocol/stream"
"go.uber.org/thriftrw/wire"
)
Expand Down Expand Up @@ -62,8 +61,6 @@ func fixedWidth(t wire.Type) int64 {

// StreamReader provides an implementation of a "stream.Reader".
type StreamReader struct {
iface.Private

reader io.Reader
buffer [8]byte

Expand Down
4 changes: 0 additions & 4 deletions protocol/binary/stream_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"math"
"sync"

"go.uber.org/thriftrw/internal/iface"
"go.uber.org/thriftrw/protocol/stream"
)

Expand All @@ -37,9 +36,6 @@ var streamWriterPool = sync.Pool{
// StreamWriter implements basic logic for writing the Thrift Binary Protocol
// to an io.Writer.
type StreamWriter struct {
// Private implementation to satisfy the private Writer interface.
iface.Impl

writer io.Writer

// This buffer is re-used every time we need a slice of up to 8 bytes.
Expand Down
7 changes: 0 additions & 7 deletions protocol/stream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ package stream
import (
"io"

"go.uber.org/thriftrw/internal/iface"
"go.uber.org/thriftrw/wire"
)

// Protocol defines a specific way for a Thrift value to be encoded or
// decoded, implemented in a streaming fashion.
type Protocol interface {
iface.Private // this interface is meant for internal implementations only

// Writer returns a streaming implementation of an encoder for a
// Thrift value.
Writer(w io.Writer) Writer
Expand Down Expand Up @@ -84,8 +81,6 @@ type ListHeader struct {
// Writer defines an encoder for a Thrift value, implemented in a streaming
// fashion.
type Writer interface {
iface.Private // this interface is meant for internal implementations only

WriteBool(b bool) error
WriteInt8(i int8) error
WriteInt16(i int16) error
Expand Down Expand Up @@ -114,8 +109,6 @@ type Writer interface {
// Reader defines an decoder for a Thrift value, implemented in a streaming
// fashion.
type Reader interface {
iface.Private // this interface is meant for internal implementations only

ReadBool() (bool, error)
ReadInt8() (int8, error)
ReadInt16() (int16, error)
Expand Down
36 changes: 0 additions & 36 deletions thrifttest/streamtest/mock_stream.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f40a16c

Please sign in to comment.