commitlog
commitlog copied to clipboard
Clarify docs about the message size limit
Hi, just trying this crate and made some minor updates to the docs about the message size limit
- minor wording
- added a doctest just as an example of the message size limit
- added a actual test just to pin that header size in the tests
Hi @equalsraf,
Thanks for the PR! One clarification, do you have code that is dependent on the header size? It may be worth externalizing as a constant if that would help.
One clarification, do you have code that is dependent on the header size?
More or less, I need to enforce a limit on the payload size and since message_max_size()
includes the header length.I need to know it to set the correct size.
I suppose the other way around it, would be to have a way to specify this based on the payload size.
/// This is a lousy example as it breaks the builder pattern, and fails to report
/// the error - perhaps add an attribute payload_max_bytes and check for sanity in
/// CommitLog::new()
pub fn payload_max_bytes(&mut self, bytes: usize) {
// FIXME: get this value from somewhere
if let Some(total) = bytes.checked_add(20) {
self.message_max_bytes = total;
}
}
I suppose the other way around it, would be to have a way to specify this based on the payload size.
Yea agreed. Thinking more about this, we'd want the maximum set by the consumer of the library to be independent of the encoding (which we could easily change later with backward compatibility).