Skip to content

S3 Stream Writer: simpler and more robust logic#136

Open
ahouene wants to merge 8 commits intoPowerDNS:mainfrom
ahouene:s3-stream-simpler-writer
Open

S3 Stream Writer: simpler and more robust logic#136
ahouene wants to merge 8 commits intoPowerDNS:mainfrom
ahouene:s3-stream-simpler-writer

Conversation

@ahouene
Copy link
Copy Markdown
Contributor

@ahouene ahouene commented Apr 1, 2026

Refactor the io.WriteCloser returned by (*s3.Backend).NewWriter to make it more robust and simple. It takes some changes out of #133, that will be rebased to result in a simpler and more obvious diff.

@ahouene ahouene requested review from Luit and neilcook April 1, 2026 14:57
@ahouene ahouene self-assigned this Apr 1, 2026
_ = pr.CloseWithError(err)
cancel()
}(ctx, b, name, pr, cancel)
return &writerWrapper{b, nil, ctx, pw}, nil
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Field assignment in this way is error prone and less readable. I prefer to see the backend: b form.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair point, I changed it!

err = w.prevErr
_ = w.pw.CloseWithError(err)
if w.prevErr == nil {
w.prevErr = simpleblob.ErrClosed
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you Close and then Write, the error returned from a second Close won't be ErrClosed here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants