Skip to content
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

Go: add support for stream handling of attachments #737

Merged
merged 1 commit into from
Nov 21, 2022

Commits on Nov 21, 2022

  1. Go: add support for stream handling of attachments

    Adds support for streaming reads and writes of attachment data. With
    this change, ParseAttachment is dropped as a public function and
    replaced with a private function, parseAttachmentReader.
    
    A new type AttachmentReader is exposed, which exposes the Data portion
    of an attachment as a reader that can be streamed. The Attachment type
    is modified to include a new ContentLength field, to allow the writer to
    write the attachment length before stream processing the body.
    
    A new option, AttachmentCallback, is exposed in the Lexer. Rather than
    emitting attachments, the Lexer now parses an attachment reader and
    calls the supplied callback (if supplied), and consumes any unconsumed
    bytes from the attachment record (whether or not a callback is
    supplied).
    
    This is a breaking change in the Go SDK, and introduces some awkwardness
    due to the presence of the new ContentLength field in the Attachment
    record. In the specification, that value is folded into the Data field,
    however this is not a tenable approach for stream handling. The actual
    binary format is not affected by this - only the way in which the binary
    format is described.
    
    This change is required for readers and writers to be able to handle
    attachments bigger than available RAM. Without it, attaching a
    sufficiently large attachment will crash the reader/writer with an OOM.
    wkalt committed Nov 21, 2022
    Configuration menu
    Copy the full SHA
    d6f8b05 View commit details
    Browse the repository at this point in the history