Open weissi opened 6 years ago
@ddunbar any input here? The 2.0 development work will start shortly
We don't have any strong need for this, it was just an idea. It would be easy to experiment by writing a SwiftPM OutputByteStream implementation which targets a channel, to see what the ergonomics of it are like.
@weissi @Lukasa is this something we still want to do?
Yeah, I think so.
We could also trial a few implementations of this in a new NIOExtrasWhatever
package. Not sure if we should add a new operator to NIO, it may have source breakage potential for users if they're in love with operators.
But I also think we should try something in this space.
suggested by @ddunbar
SwiftNIO might be appealing to developers of network servers that need good but maybe not the best network performance. In these cases, the allocate
ByteBuffer
, accumulate,ctx.write
, ...,ctx.flush
might be a bit awkward. A simpler API might also be a good starting point. ForChannelHandlers
withOutboundOut = ByteBuffer
, @ddunbar proposed the following API:which would basically do:
and I guess we could also offer a
ctx.writeAndFlushWithStream
API. Or maybectx.writeWithStream(flush: Bool = false, (Stream) -> EventLoopPromise<()>) -> EventLoopPromise<()>
🤔.The custom
<<<
operator would be defined for everything we accept:ByteBuffer
,(Contiguous)Collection of UInt8
,String
,StaticString
, the various integers, ...We should definitely evaluate having such a more high-level API.
This should probably live in some yet to be created
NIOExtras
module. And we need to think about how to make it perform well and in an unsurprising way.