Change interface to expect a function rather than a stream instance

A new stream instance is needed for every new connection so we can't
reuse a single instance.
2.0.0