commitlog icon indicating copy to clipboard operation
commitlog copied to clipboard

Clarify docs about the message size limit

Open equalsraf opened this issue 7 years ago • 3 comments

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

equalsraf avatar Jul 25 '17 17:07 equalsraf

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.

zowens avatar Jul 26 '17 02:07 zowens

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;
        }
    }

equalsraf avatar Jul 26 '17 08:07 equalsraf

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).

zowens avatar Jul 26 '17 16:07 zowens