Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnceErr ¶ added in v0.5.0
OnceErr returns a function that invokes fn at most once, no matter how many goroutines call the returned function, and how often. Every caller receives the same (T, error) pair produced by that single call.
It is the error-returning equivalent of sync.OnceValue.
Example:
load := conker.OnceErr(func() (*Config, error) {
return loadConfig("config.yaml")
})
cfg, err := load() // loads config.yaml
cfg, err = load() // returns the cached result; fn is not called again
Types ¶
type WaitGroup ¶
type WaitGroup struct {
// contains filtered or unexported fields
}
WaitGroup is a panic-safe wrapper around sync.WaitGroup that propagates panics from goroutines spawned with WaitGroup.Go to the caller of WaitGroup.Wait or WaitGroup.WaitAndRecover.
The zero value is ready to use. WaitGroup is reusable across multiple Wait cycles when no panic occurs. If a goroutine panics, create a new WaitGroup for subsequent work rather than reusing the same instance.
Example — basic usage:
var wg conker.WaitGroup
wg.Go(func() { doWork() })
wg.Go(func() { doMoreWork() })
wg.Wait() // re-panics if any goroutine panicked
Example — recovering from a panic without propagating:
var wg conker.WaitGroup
wg.Go(func() { riskyWork() })
if r := wg.WaitAndRecover(); r != nil {
log.Printf("goroutine panicked at:\n%s", r.Stack)
}
func (*WaitGroup) Go ¶
func (w *WaitGroup) Go(f func())
Go spawns f in a new goroutine. Any panic raised by f is captured and surfaced when WaitGroup.Wait or WaitGroup.WaitAndRecover is called, with the stack trace preserved at the original panic site.
func (*WaitGroup) Wait ¶
func (w *WaitGroup) Wait()
Wait blocks until all goroutines launched with WaitGroup.Go have returned, then re-panics with the first captured panic as a *panics.Recovered. It is a no-op if no goroutine panicked.
func (*WaitGroup) WaitAndRecover ¶
WaitAndRecover blocks until all goroutines launched with WaitGroup.Go have returned and returns the first captured panic, or nil if none occurred.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package daemon provides a pool of long-lived workers ("daemons") that run until told to stop, with graceful-shutdown semantics.
|
Package daemon provides a pool of long-lived workers ("daemons") that run until told to stop, with graceful-shutdown semantics. |
|
examples
|
|
|
background-services
command
Example: background-services
|
Example: background-services |
|
etl-pipeline
command
Example: etl-pipeline
|
Example: etl-pipeline |
|
fleet-healthcheck
command
Example: fleet-healthcheck
|
Example: fleet-healthcheck |
|
log-enrichment
command
Example: log-enrichment
|
Example: log-enrichment |
|
Package iter provides concurrent iteration over Go 1.23 iterators (iter.Seq and iter.Seq2) and Go maps.
|
Package iter provides concurrent iteration over Go 1.23 iterators (iter.Seq and iter.Seq2) and Go maps. |
|
Package panics provides typed panic recovery that integrates with Go's standard errors package.
|
Package panics provides typed panic recovery that integrates with Go's standard errors package. |
|
Package pool provides a bounded, panic-safe task runner with support for recursive task submission.
|
Package pool provides a bounded, panic-safe task runner with support for recursive task submission. |
|
Package stream provides ordered concurrent processing: producer functions run concurrently, but their returned callbacks execute serially in submission order.
|
Package stream provides ordered concurrent processing: producer functions run concurrently, but their returned callbacks execute serially in submission order. |