r3labs / sse

Server Sent Events server and client for Golang
Mozilla Public License 2.0
870 stars 180 forks source link

Introduce EventLog BufferSize #169

Open tchaton opened 1 year ago

tchaton commented 1 year ago

Hey there,

Thanks for this nice framework.

I would like to request the addition of a mechanism to limit the size of the EventLog to tail the latest ones in memory.

This can be done by patching the EventLog as follows:

    if len(stream.Eventlog) >= Limitsize {
        L := len(stream.Eventlog)
        stream.Eventlog =stream.Eventlog[L-Limitsize : L-1]
    }
aywan commented 1 year ago

Hi! Same problem, current implementation of EventLog is memory leaking) I think some kind of circular/ring buffer be better, than copy and extend slice every time.