concurrency

command
v0.0.0-...-90bf800 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 9 Imported by: 0

README

Example demonstrates a scenario where client calls many subscribe and RPC commands, and we process them concurrently on server side.

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.

In real application you may want to use goroutine pools for operations to have a better control on program memory consumption.

To start example run the following command from example directory:

go run main.go

Then go to http://localhost:8000 to see it in action.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL