• Felix Lange's avatar
    rpc: ensure client doesn't block for slow subscribers · f5f042ff
    Felix Lange authored
    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.
    f5f042ff
Name
Last commit
Last update
.github Loading commit data...
Godeps Loading commit data...
_data Loading commit data...
accounts Loading commit data...
build Loading commit data...
cmd Loading commit data...
common Loading commit data...
compression/rle Loading commit data...
console Loading commit data...
containers Loading commit data...
core Loading commit data...
crypto Loading commit data...
errs Loading commit data...
eth Loading commit data...
ethdb Loading commit data...
event Loading commit data...
generators Loading commit data...
internal Loading commit data...
light Loading commit data...
logger Loading commit data...
metrics Loading commit data...
miner Loading commit data...
node Loading commit data...
p2p Loading commit data...
params Loading commit data...
pow Loading commit data...
release Loading commit data...
rlp Loading commit data...
rpc Loading commit data...
tests Loading commit data...
trie Loading commit data...
whisper Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
COPYING Loading commit data...
COPYING.LESSER Loading commit data...
Makefile Loading commit data...
README.md Loading commit data...
VERSION Loading commit data...
appveyor.yml Loading commit data...
circle.yml Loading commit data...