Easily run concurrent goroutines safely
- Easy to use: Get up and running with the library in minutes
- Intuitive: Get access to a powerful pattern within software development, without encountering common pitfalls or mistakes!
- Actively developed: Ideas and contributions welcomed!
Getting Started
concur
is a Go library that allows you to safely and easily implement a concurrency pattern in your codebase. Install the latest version, and get up and running in minutes.
This library is currently used by the Five9-GO repository, to provide a reliable, safe way to interact with the Five9 API Websocket service.
What is concurrency, and why is it useful?
Concurrency is the composition of independently executing computations.
Concurrency is a way to structure software, particularly as a way to write clean code that interacts well with the real world.
It is not parallelism.
- Rob Pike, 2012
Simply put, concurrency in software allows you to create fast, robust systems that can be relied upon to be consistent. Some examples of what concurrency can do, as provided by the Go team:
Common pitfalls of concurrency that this library prevents
- Race conditions
- Deadlocks
- Unpredictable or "flaky" tests when testing concurrent data models (such as Websockets, which are inherently asynchronous messages being sent back and forth between systems)
Install
go get github.com/equalsgibson/concur@v0.0.3
Example of ASyncReader
Run the example ASyncReader with a mock asynchronous resource, along with a CPU and Memory profile.
https://github.com/equalsgibson/concur/blob/e3d8905e740043133e92e11918fd1c2e47d7e0e3/examples/async_reader_timer.go/main.go#L1-L109
Expected Output:
cgibson@wsl-ubuntuNexus:~/concur$ go run examples/async_reader_timer.go/main.go -cpuprofile cpu.prof -memprofile mem.prof
2024/10/29 00:01:00 Current Iteration: 1 - Current goroutines: 4
2024/10/29 00:01:01 Current Iteration: 2 - Current goroutines: 4
...
2024/10/29 00:01:03 Current Iteration: 299 - Current goroutines: 4
2024/10/29 00:01:03 Current Iteration: 300 - Current goroutines: 4
2024/10/29 00:01:05 Got an error response from Loop fetch function: end of the example - thanks for using the concur package
You can then analyze the profiles created, using the pprof tool
Contributing
Contributions are what make the open source community such an amazing place to learn, get inspired, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
)
- Commit your Changes (
git commit -m 'Add some AmazingFeature'
)
- Push to the Branch (
git push origin feature/AmazingFeature
)
- Open a Pull Request
License
Distributed under the MIT License. See LICENSE.txt
for more information.
Chris Gibson (@equalsgibson)
Project Link: https://github.com/equalsgibson/concur
Acknowledgments