diff options
author | Felix Lange <fjl@twurst.com> | 2016-08-05 03:18:13 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-08-06 02:48:33 +0800 |
commit | f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537 (patch) | |
tree | 2c7fc00059c94a9178b6e75e29f31a3cacc2b68b /rpc/inproc.go | |
parent | 464660651ddf7e8938a0fbb03f140502180a8062 (diff) | |
download | dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar.gz dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar.bz2 dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar.lz dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar.xz dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.tar.zst dexon-f5f042ffdc9fed3094b86f3dbbc85bb63a4f9537.zip |
rpc: ensure client doesn't block for slow subscribers
I initially made the client block if the 100-element buffer was
exceeded. It turns out that this is inconvenient for simple uses of the
client which subscribe and perform calls on the same goroutine, e.g.
client, _ := rpc.Dial(...)
ch := make(chan int) // note: no buffer
sub, _ := client.EthSubscribe(ch, "something")
for event := range ch {
client.Call(...)
}
This innocent looking code will lock up if the server suddenly decides
to send 2000 notifications. In this case, the client's main loop won't
accept the call because it is trying to deliver a notification to ch.
The issue is kind of hard to explain in the docs and few people will
actually read them. Buffering is the simple option and works with close
to no overhead for subscribers that always listen.
Diffstat (limited to 'rpc/inproc.go')
0 files changed, 0 insertions, 0 deletions