sse icon indicating copy to clipboard operation
sse copied to clipboard

Feature: make an option to provide buffer size for client scanner

Open Venoox opened this issue 3 years ago • 5 comments

I'm trying to use client from this module and the problem I keep having is that the buffer is too small because server is sending events with data larger than max token size from bufio (MaxScanTokenSize). I can also code this feature and make a PR but I'm not sure what's the best way to go about it. Would you be interested in adding this feature?

Venoox avatar Oct 02 '21 20:10 Venoox

Are you saying that, in client mode, a server that is outside of your control is sending events that are larger than 64 KB? (https://pkg.go.dev/bufio#pkg-constants)

codewinch avatar Nov 06 '21 21:11 codewinch

Yes, exactly

Venoox avatar Nov 06 '21 21:11 Venoox

Hey @Venoox , very sorry for not getting back to you sooner!

I think this sounds like a good feature to have. If you still have a need for it, I can try to implement some options for MaxScanTokenSize, unless you would prefer to give it a go?

purehyperbole avatar Nov 09 '21 20:11 purehyperbole

@Venoox You should now be able to configure the bufio scanner size in 2.7.0 like so:

// sets the buffer size to 1 << 19 (524288 bytes)
c := sse.NewClient(url, sse.ClientMaxBufferSize(1<<19))

Please let me know if this has fixed your issue

purehyperbole avatar Nov 10 '21 11:11 purehyperbole

This fixes https://github.com/chmouel/gosmee/issues/77.

portante avatar Apr 27 '23 00:04 portante