Fork me on GitHub
#aleph
<
2018-12-03
>
igrishaev15:12:15

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?

igrishaev15:12:51

And what will happen if I drop the trailing (s/buffer 100)?

rborer15:12:34

I believe that without the buffer sending a message from a client would "block" until all participants have received it

rborer15:12:49

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

rborer15:12:43

Well no, it depends on the implementation of event-bus

igrishaev15:12:30

Well, I got it as pre-loading a certain amount of messages in advance

igrishaev15:12:57

Like the do when reading a file from a disk.

rborer15:12:15

yeah, but then the example wouldn't work, right? I mean, the example is sending a single message by each client 😕

igrishaev15:12:34

It would. There is a video when the author says, without a buffer a slow client may slow down everybody

pithyless17:12:33

@igrishaev - this is where ztellman talks about buffering and throttling chats: https://www.youtube.com/watch?v=1bNOO3xxMc0&amp;t=1887