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

New design for Producers and Consumers #80

Closed
Geal opened this issue Sep 7, 2015 · 1 comment
Closed

New design for Producers and Consumers #80

Geal opened this issue Sep 7, 2015 · 1 comment
Milestone

Comments

@Geal
Copy link
Collaborator

Geal commented Sep 7, 2015

The actual design for producers and consumers is not very flexible, and very slow. For the 1.0 version, they should be modified to allow for better streaming patterns.

List of current problems:

  • pusher!, Stepper, AccReader and Consumer all have their own buffer to partially consume data and accumulate more bytes. This results in a lot of clearing and filling of buffers
  • the pusher macro is not really useful
  • the Consumer pattern is confusing, since it handles data consumption in a loop. What most people ask for currently is the Stepper.
  • the Producer's buffer size is fixed, it cannot change once we know more about the format
  • the signals between Producer and Consumer could make it easier to indicate more data, seeking needed, etc

Ideas for the new design:

  • I really like how Haskell's pipes and conduit work, the yield and await calls are useful patterns. Unfortunately, they are not doable in Rust without either a coroutine implementation, or a syntax extension writing a complete state machine. But we can still take inspiration from those projects
  • the Producer's buffer should handle data accumulation and consumption. The new API could look like AccReader's, with a a BufRead implementation to indicate how much data has been consumed. This would avoid a lot of data copy in the rest of the pipe
  • the Producer's buffer size should be changeable. This implies that data must be copied, of course
  • there could be a "middle" component, like a pipe, and a way to combine them like pipes or conduit do it, such as Producer + Pipe == Producer, Pipe + Pipe == Pipe, Pipe + Consumer == Consumer
  • more error reporting for Stepper and Consumer

any other ideas?

@Geal
Copy link
Collaborator Author

Geal commented Nov 16, 2015

Fixed in 1.0

@Geal Geal closed this as completed Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant