Repository navigation
refactor: typed_kv::adapter should use Buffer - #4497
Conversation
Signed-off-by: tison <[email protected]>
d7e14ce to
1848ff7
Compare
57acf27 to
d7882b7
Compare
Signed-off-by: tison <[email protected]>
d7882b7 to
482ff97
Compare
| self.buffer.advance(written); | ||
| } | ||
|
|
||
| let buffer = std::mem::take(&mut self.buffer); |
There was a problem hiding this comment.
I'm not sure if we need loop still. Generally &mut self should take the ref exclusive. But I'm not quit sure.
There was a problem hiding this comment.
If .await can give up the mut ref, we always have the risk the before close, there is a new push.
There was a problem hiding this comment.
Close could fail and users might retry close later, we should keep buffer in memory until users decide to drop this writer.
| let written = self.inner.write(self.buffer.collect()).await?; | ||
| self.buffer.advance(written); | ||
| let buffer = std::mem::take(&mut self.buffer); | ||
| self.inner.write(buffer.collect()).await?; |
There was a problem hiding this comment.
This is incorrect because write does not guarantee that all content will be successfully written. We need to advance the written size here and keep unwritten content.
There was a problem hiding this comment.
Then it's meaningless to make collect takes mut self. Please push a new commit on this patch or write a new PR.
| self.buffer.advance(written); | ||
| } | ||
|
|
||
| let buffer = std::mem::take(&mut self.buffer); |
There was a problem hiding this comment.
Close could fail and users might retry close later, we should keep buffer in memory until users decide to drop this writer.
This reverts commit 482ff97.
Signed-off-by: Xuanwo <[email protected]>
|
gcs failed for #4439, need more research but we know that it's not related to this PR. |
|
Cool. That change makes sense. |
This closes #4480.