chore: adjusted SegmentWriter to the reader conversion (#13342)

Signed-off-by: Vladyslav Diachenko <vlad.diachenko@grafana.com>
Co-authored-by: George Robinson <george.robinson@grafana.com>
Co-authored-by: Ben Clive <ben.clive@grafana.com>
pull/13289/merge
Vladyslav Diachenko 11 months ago committed by GitHub
parent 7f35179cd3
commit 33bd390f19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      pkg/storage/chunk/client/object_client.go

@ -107,12 +107,14 @@ func (o *client) Stop() {
}
func (o *client) PutWal(ctx context.Context, segment *wal.SegmentWriter) error {
buffer := bytes.NewBuffer(nil)
_, err := segment.WriteTo(buffer)
reader, err := segment.ToReader()
if err != nil {
return err
}
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), bytes.NewReader(buffer.Bytes()))
defer func(reader io.ReadSeekCloser) {
_ = reader.Close()
}(reader)
return o.store.PutObject(ctx, "wal-segment-"+time.Now().UTC().Format(time.RFC3339Nano), reader)
}
// PutChunks stores the provided chunks in the configured backend. If multiple errors are

Loading…
Cancel
Save