Skip to content

Commit

Permalink
remove ASBEncoder writer field
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike committed Feb 22, 2024
1 parent d0ac95f commit 8e68d33
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
1 change: 0 additions & 1 deletion backup_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ func (bwh *BackupToWriterHandler) Wait() error {
}

func getDataWriter(eb EncoderBuilder, w io.Writer, namespace string, first bool) (datahandlers.Writer, error) {
eb.SetDestination(w)
enc, err := eb.CreateEncoder()
if err != nil {
return nil, err
Expand Down
1 change: 0 additions & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ type Encoder interface {

type EncoderBuilder interface {
CreateEncoder() (Encoder, error)
SetDestination(dest io.Writer)
}

// BackupBaseConfig contains shared configuration for backup operations
Expand Down
11 changes: 3 additions & 8 deletions encoder/asb.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"encoding/base64"
"errors"
"fmt"
"io"
"math"
"time"

Expand All @@ -31,14 +30,10 @@ const (
ASBFormatVersion = "3.1"
)

type ASBEncoder struct {
writer io.Writer
}
type ASBEncoder struct{}

func NewASBEncoder(w io.Writer) (*ASBEncoder, error) {
return &ASBEncoder{
writer: w,
}, nil
func NewASBEncoder() (*ASBEncoder, error) {
return &ASBEncoder{}, nil
}

func (o *ASBEncoder) EncodeRecord(rec *models.Record) ([]byte, error) {
Expand Down
6 changes: 2 additions & 4 deletions encoder/asb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ type asbEncoderTestSuite struct {
}

func (suite *asbEncoderTestSuite) TestEncodeRecord() {
dst := &strings.Builder{}
encoder, err := NewASBEncoder(dst)
encoder, err := NewASBEncoder()
if err != nil {
suite.FailNow("unexpected error: %v", err)
}
Expand Down Expand Up @@ -70,8 +69,7 @@ func (suite *asbEncoderTestSuite) TestEncodeRecord() {
}

func (suite *asbEncoderTestSuite) TestEncodeSIndex() {
dst := &strings.Builder{}
encoder, err := NewASBEncoder(dst)
encoder, err := NewASBEncoder()
if err != nil {
suite.FailNow("unexpected error: %v", err)
}
Expand Down
11 changes: 1 addition & 10 deletions encoders.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,8 @@ func NewASBEncoderBuilder() *ASBEncoderBuilder {
return &ASBEncoderBuilder{}
}

// SetDestination sets the destination for the ASBEncoder
// This is method is called by the backup client to set the destination
// Users of the backup client should not call this method
func (f *ASBEncoderBuilder) SetDestination(dst io.Writer) {
f.dst = dst
}

// CreateEncoder creates a new ASBEncoder
// This method is called by the backup client to create a new encoder
func (f *ASBEncoderBuilder) CreateEncoder() (Encoder, error) {
return encoder.NewASBEncoder(
f.dst,
)
return encoder.NewASBEncoder()
}

0 comments on commit 8e68d33

Please sign in to comment.