clj-commons / manifold

A compatibility layer for event-driven abstractions
1.02k stars 106 forks source link

Upstream flag in `connect` doesn't seem to work #56

Closed dm3 closed 8 years ago

dm3 commented 8 years ago

Given the following:

(deftest test-connect-filter
  (let [s1 (s/stream)
        s2 (s/stream)]
    (s/connect s1 s2 {:upstream? true})
    (s/close! s2)
    (is (s/closed? s2))
    (is (s/closed? s1)))

the test fails as s1 is still open.

According to the documentation of connect I would expect both s1 and s2 to be closed after closing s2, even without specifying the upstream? flag as s2 is the only downstream sink. However, even when :upstream? is true, s1 stays open.

Could you please take a look if is either a gross misunderstanding on my side or a bug?

ztellman commented 8 years ago

The upstream closing behavior isn't immediate, it will only take effect when s1 tries to convey a message to s2 and fails because it's closed. I'l think about how to make the documentation clearer on this point.

I'm going to close this issue, but feel free to ask any further questions you have.

dm3 commented 8 years ago

Thank you! Would be great if you could add that to the docs.

Also would be great if you could elaborate how the drained/closed states differ, maybe with some examples in the docs.