Skip to content

Pure ByteStream interface - #133

Merged
lovelydinosaur merged 5 commits into
masterfrom
pure-bytestream-interface
Aug 6, 2020
Merged

Pure ByteStream interface#133
lovelydinosaur merged 5 commits into
masterfrom
pure-bytestream-interface

Conversation

@lovelydinosaur

@lovelydinosaurlovelydinosaur commented Aug 5, 2020

Copy link
Copy Markdown
Contributor

This pull request ensures that our AsyncByteStream and SyncByteStream classes are pure interface classes, without any implementations themselves.

It also introduces the following concrete implementations, which act as helpful classes for developers, so that it's not always strictly necessary to implement a concrete class.

stream=httpcore.PlainByteStream(b"123")
stream=httpcore.IteratorByteStream(iterator=...) # Optionally, also `close_func=...`.stream=httpcore.AsyncIteratorByteStream(aiterator=...) # Optionally, also `aclose_func=...`.

Developers don't need to use our concrete implementations, as they could instead provide their own implementations, but this change gives us both a nice purity of interface, and the convenience of providing a few very basic implementations.

@lovelydinosaurlovelydinosaur added this to the 0.10.0 milestone Aug 5, 2020
@lovelydinosaurlovelydinosaur changed the title Pyte ByteStream interfacePure ByteStream interfaceAug 5, 2020
@lovelydinosaurlovelydinosaur added the enhancement New feature or request label Aug 5, 2020

@florimondmancaflorimondmanca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions on naming, but 💯 sold on the idea!

Comment threadhttpcore/_bytestreams.py Outdated
Comment threadhttpcore/_bytestreams.py Outdated
@lovelydinosaur
lovelydinosaur merged commit 2b85b00 into masterAug 6, 2020
@lovelydinosaur
lovelydinosaur deleted the pure-bytestream-interface branch August 6, 2020 11:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancementNew feature or request

Development

Successfully merging this pull request may close these issues.

2 participants

@lovelydinosaur@florimondmanca