Hi, just a small question. While reading aleph Websockets samples, I found this:
;; take all messages from the client, prepend the name, and publish it to the room
(s/consume
#(bus/publish! chatrooms room %)
(->> conn
(s/map #(str name ": " %))
(s/buffer 100)))
What’s the meaning here of wrapping the source stream with a buffer? As far as I understand, it’s important when sending messages into a stream. But what does buffering when reading messages?And what will happen if I drop the trailing (s/buffer 100)
?
I believe that without the buffer sending a message from a client would "block" until all participants have received it
Per https://github.com/ztellman/manifold/blob/master/docs/stream.md#buffers-and-backpressure > We saw above that if we attempt to put a message into a stream, it won't succeed until the value is taken out. This is because the default stream has no buffer
Well no, it depends on the implementation of event-bus
Well, I got it as pre-loading a certain amount of messages in advance
Like the do when reading a file from a disk.
yeah, but then the example wouldn't work, right? I mean, the example is sending a single message by each client 😕
It would. There is a video when the author says, without a buffer a slow client may slow down everybody
@igrishaev - this is where ztellman talks about buffering and throttling chats: https://www.youtube.com/watch?v=1bNOO3xxMc0&t=1887