Debian Codegraph @

_examples/concurrency/readme.md

raw
1 Example demonstrates a scenario where client calls many subscribe and RPC commands, and we process them concurrently on server side.
2
3 Here we emulate potentially slow operation in Subscribe and RPC handlers by sleeping on some time. To avoid blocking client connection read loop we run these slow operations in goroutines. A bounded semaphore inside client connect closure used to limit concurrency of operations running in goroutines for a single client connection.
4
5 In real application you may want to use goroutine pools for operations to have a better control on program memory consumption.
6
7 To start example run the following command from example directory:
8
9 ```
10 go run main.go
11 ```
12
13 Then go to http://localhost:8000 to see it in action.