Closed marcoonroad closed 5 years ago
BUMP:
The close operation should be deterministic and somehow idempotent. If the producer wishes to break consumers, it could send/publish Error
objects and make consumers fail due that by implementing an internal handling logic.
While the
stream
abstraction provides a custom value (mostly anError
) to close itself, theError
for thechannel
abstraction is hard-coded and fixed for close operations. The differences are shown below:Stream's close operation: https://github.com/marcoonroad/sporadic/blob/b664f9fa2d931c3ba47fb0e710cf70c2e385778b/src/sporadic/streams/index.js#L68-L82
Channel's close operation: https://github.com/marcoonroad/sporadic/blob/b664f9fa2d931c3ba47fb0e710cf70c2e385778b/src/sporadic/channels/index.js#L77-L88
I should fix that. The API for close operations must be the same. If I allow the user to provide custom
Error
messages, there may be a non-determinism / race condition to break/throw such abstractions. If I fix theError
messages as hard-coded ones, all abstractions would deterministically break, the close operation here would be idempotent.I should think carefully in such design tradeoffs therefore.