-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Retry refactor to allow for batching to retry. #617
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a number of stylistic concerns that I've left as comments throughout the code.
In general your approach seems sound. However, I would really like to see some unit tests added for this retry logic in order to validate that it performs as expected.
@@ -15,6 +15,7 @@ const BATCHSIZE = 256 * 1024 | |||
|
|||
type HTTPSBatchWriter struct { | |||
HTTPSWriter | |||
*Retryer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why embed *Retryer
rather than using a named field to encapsulate the new struct via composition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that I would prefer composition in this case because I don't see a good reason to exposes the fields and methods of *Retryer
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was using a Pointer here, so that I could insert the retryer by creating it in the writer factory layer, so that the implementation and logic does not rely on the writers itself to propagate the settings through to the retryer.
Might be a shortcoming due to my limited understanding of Go idiomatic concepts.
) | ||
|
||
// RetryWriter wraps a WriteCloser and will retry writes if the first fails. | ||
type Retryer struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just represent Retryer
as some new fields and methods in HTTPSBatchWriter
since that's the only writer set to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion on this, but I think I lean toward just putting all this code into HTTPSBatchWriter
so that it's all more self-contained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about that as well, but when one would introduce the retryer in the way I built it here, it would have more than one benefit:
- Retrying after stringifying the rfsyslog message seemed beneficial performance wise.
- Having a connection aware retry logic for tls based approaches might result in a more efficient approach to solve connectivity issues (retries are only needed due to connectivity issues)
- the retry_writer retries parsing issues for syslog messages #612 is also present for tls/tcp writers. this could be fixed with a dedicated pr.
Description
This change mostly changes around, where the retry logic is applied.
Thinking about the things that need to be retried, this is likely to only be needed for networking.
So the logic of retrying should be done after the serialisation of the data for every protocol, to increase performance and locality of problem solutions.
Type of change
Testing performed?
Checklist:
main
branch, or relevant version branchIf you have any questions, or want to get attention for a PR or issue please reach out on the #logging-and-metrics channel in the cloudfoundry slack