conc
by
sourcegraph

Description: Better structured concurrency for go

View on GitHub ↗

Summary Information

Updated 40 minutes ago
Added to GitGenius on May 24th, 2024
Created on January 2nd, 2023
Open Issues & Pull Requests: 30 (+0)
Number of forks: 360
Total Stargazers: 10,414 (+0)
Total Subscribers: 63 (+0)

Issue Activity (beta)

Open issues: 17
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 543 days
Stale 30+ days: 17
Stale 90+ days: 17

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

No label distribution available yet.

Most active issues this week

No issue events were indexed in the last 7 days.

Repository Insights (GitGenius)

Median issue/PR response: 24.5 hours
Mean response time: 85.7 days
90th percentile: 379.1 days
Tracked items: 17

Most active contributors

Detailed Description

The conc repository is a Go package developed by Sourcegraph that provides structured concurrency primitives designed to make concurrent programming safer and more readable. The package addresses three core pain points in Go's concurrency model: goroutine leaks, unhandled panics in concurrent code, and the verbosity of writing correct concurrent patterns.

The package offers multiple abstractions for different concurrency scenarios. At the foundation is conc.WaitGroup, a safer alternative to the standard library's sync.WaitGroup. For bounded concurrency, the package provides pool.Pool for running tasks with a maximum goroutine limit, and pool.ResultPool for collecting results from concurrent tasks. Additional pool variants include ErrorPool for handling fallible tasks, ContextPool for canceling tasks on failure, and combinations like ResultErrorPool and ResultContextPool. For stream processing, stream.Stream enables parallel processing of ordered task sequences while maintaining serial callbacks. The iter package provides convenience functions like iter.Map and iter.ForEach for concurrent operations over slices. The panics.Catcher utility allows developers to safely catch panics spawned in goroutines.

The design philosophy centers on scoped concurrency, where all goroutines must have an explicit owner responsible for ensuring proper cleanup. This prevents the common pattern of fire-and-forget goroutines that leak resources. When goroutines panic, the Wait method will propagate the panic to the caller with decorated stack traces from child goroutines, ensuring panic information is not lost. This approach eliminates the need for developers to manually implement panic recovery boilerplate in every concurrent operation.

The package is written in Go and is classified across multiple development tool categories including source code search, code intelligence, semantic analysis, and developer productivity tools. According to GitGenius activity tracking, the repository shows a median issue and pull request response latency of 24.5 hours across 17 tracked items, with a mean latency of 2056.5 hours. The most active contributors tracked include camdencheek with 8 events, followed by gaby and sam-ulrich1 with 3 events each. The repository shares overlapping contributors with spinnaker/spinnaker, getify/you-dont-know-js, and bregman-arie/devops-exercises.

The package documentation emphasizes reducing boilerplate through high-level abstractions. Rather than manually managing goroutines with sync.WaitGroup and error channels, developers can use pool.New to create a bounded task runner or iter.Map for concurrent slice operations. Configuration methods like WithMaxGoroutines, WithErrors, WithContext, WithFirstError, and WithCollectErrored allow fine-grained control over pool behavior. The repository includes extensive examples comparing stdlib approaches with conc equivalents, demonstrating significant reductions in code complexity for common patterns like spawning goroutines, processing streams, iterating slices, and maintaining order in concurrent operations.

At the time of the README documentation, the package was in pre-1.0 status with a targeted 1.0 release for March 2023, indicating the API was still stabilizing. The project is backed by Sourcegraph's development infrastructure and is positioned as a practical toolkit for developers seeking to write safer, more maintainable concurrent Go code.

conc
by
sourcegraphsourcegraph/conc

Repository Details

Fetching additional details & charts...