rakyll/coop is an open-source project on GitHub with 1.2k stars, written primarily in Go. Cheat sheet for some of the common concurrent flows in Go
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Note: This package became obsolete. I started it when I was learning Go a couple of years ago. I see so many better ways to implement them all now, so don't keep using this package as an ultimate reference.
coop contains some of the most common concurrent program flows I personally use in Go. I'm suggesting you to use this package as a snippets reference/cheat sheet instead of a library. The functionally provided in this package can be obtained in many different ways, and frankly with more performant implementations depending on the type of your problem.
coop contains implementations for the following flows:
coop.At(time, fn)
Runs fn at t, returns a boolean channel that will receive a message after fn returns. The following example, prints "Hello World" in a minute and blocks the goroutine its running in until fn is completed.
done := coop.At(time.Now().Add(time.Minute), func() {
fmt.Println("Hello world")
})
<-done // wait for fn to be done
coop.Until(time, duration, fn)
Runs fn once in every provided duration until t, returns a boolean channel that will receive a message after fn returns. The following example prints "Hello world" every minute until tomorrow, and blocks the goroutine its running in until the job is completed.
Runs fn after duration, returns a boolean channel that will receive a message after fn returns. The following example prints "Hello world" after a second and blocks until fn is completed.
Runs fn, and cancels the running job if timeout is exceeded. The following example will timeout and fn will return immediately ("Hello world will not printed"), the value read from the done channel will be false if timeout occurs, true if fn is completed.
done := coop.Timeout(time.Second, func() {
time.Sleep(time.Hour)
fmt.Println("Hello world")
})
<-done // will return false, because timeout occurred
coop.All(fns...)
Runs the list of fns concurrently, returns a boolean channel that will receive a message after all of the fns are completed. The following example will start 4 printing jobs concurrently and wait until all of them are completed.
Similar to coop.All, but with limiting. Runs the list of fns concurrently, but at most num fns at a time. Returns a boolean channel that will receive a message after all of the fns are completed. The following example will start 3 printing jobs immediately, and run the left out one once the first 3 is completed. It will block the goroutine until all 4 are finished.
Runs fn n time concurrently, returns a boolean channel that indicates all runs are completed. The following example prints "Hello world" 5 times, and waits for all printing jobs are finished.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
The most recent commit recorded on rakyll/coop was 10.9 years ago, based on the GitHub push timestamp. The repository has 44 forks — one of the better signals of community interest.
How many stars does rakyll/coop have?
rakyll/coop has 1.2k GitHub stars — refresh the page for the live number, or check github.com/rakyll/coop. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is rakyll/coop open source?
TopGit's metadata for rakyll/coop does not record a license. Most public repositories on GitHub ARE open source, but the exact terms vary — verify by opening the LICENSE file directly.
What is rakyll/coop?
rakyll/coop (rakyll/coop) is a Go project on GitHub. From the project's own README: Cheat sheet for some of the common concurrent flows in Go
What language is rakyll/coop written in?
rakyll/coop is written primarily in Go. GitHub's language field is based on the largest share of bytes in the default branch.
Where do I read more about rakyll/coop?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/rakyll/coop is the definitive source.
Read full README in the tab above.
Is coop worth your time?
ChatGPT, Claude and Perplexity can all read this page. Ask one of them what it makes of coop.