-
Notifications
You must be signed in to change notification settings - Fork 1
Stream2py design notes
source_reader = SourceReader(**s)
stream_buffer = StreamBuffer(source_reader, **b)
buffer_reader = BufferReader(stream_buffer, **r)buffer_reader = SourceReader(**s).stream_buffer(**b).buffer_reader(**r)buffer_reader = Aggreg(
source_reader=SourceReader(**s),
stream_buffer=StreamBuffer(**b),
buffer_reader=BufferReader(**r)
)buffer_reader = Aggreg(**s, **b, **r)As a general rule, I'm for breaking things into small objects like the three objects we're talking about here, then combining them to get interfaces that might be more appropriate for some contexts.
This means that the two aggregators above don't preclude the other two proposals. In fact, I would argue that they should be built using the fluent interface or straight code methods.
The nested aggregator nicely separates the three roles and their parameters. The same parameter name (with different values) can be used in more than one role. On the other hand, the flat aggregator allows one to share and align parameters, and only a few of the params are actually required, allows for a sparse simple interface for most cases.
Lets take this as the point of departure:
stream_reader = SourceReader(**s).stream_buffer(**b).mk_reader(**r)We want to make a StreamReader that gives us the chain automatically with default (smart or not) b and r params,
but with a means to specify these if and when needed.
We could do the flat version:
stream_reader = StreamReader(**s, **b, **r)
Or more like this this:
```python
dflt_stream_reader = StreamReader(**s) # .stream_buffer(**b).mk_reader(**r) done automatically with defaults
stream_reader_with_custom_reader = StreamReader(**s).mk_reader(**r) # .stream_buffer(**b) done automatically with defaults
stream_reader_with_custom_buffer = StreamReader(**s).stream_buffer(**b) # .mk_reader(**r) done automatically with defaults
stream_reader_with_all_customs = StreamReader(**s).stream_buffer(**b).mk_reader(**r)A problem to keep an eye on with the above is that we want multiple readers to share the same source and buffer.