Skip to content

v2: Add streaming support for large feeds #256

@mmcdole

Description

@mmcdole

Overview

Implement true streaming support for gofeed to handle large feeds efficiently without loading entire documents into memory.

Tasks

Feed Detection

  • Rewrite feed type detection to use fixed-size buffer (e.g., 8KB)
  • Use io.MultiReader to reconstruct complete reader after detection
  • Ensure no data is lost during detection phase

Streaming Parse Methods

  • Design streaming API that returns iterator/channel of items
  • Implement for each format (RSS, Atom, JSON)
  • Add MaxItems support that actually stops reading (not just skipping)
  • Consider error handling in streaming context

Benefits

  • Handle arbitrarily large feeds without memory issues
  • Process items as they're parsed rather than after full parse
  • True MaxItems support that stops reading early
  • Better performance for large feeds

API Considerations

// Possible API designs
iter, err := parser.ParseStream(reader, opts)
for iter.Next() {
    item := iter.Item()
    // Process item
}

// Or channel-based
items, errs := parser.ParseStreamChan(reader, opts)
for item := range items {
    // Process item
}

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions