mirror of
https://github.com/foomo/gofuncy.git
synced 2025-10-16 12:25:41 +00:00
1.7 KiB
1.7 KiB
gofuncy
Stop using
go func, start usinggofuncy!
- ctx as a first class citizen
- error return as a first class citizen
- optional: enable telemetry (metrics & traces)
gofuncy.routine.countcountergofuncy.routine.durationhistogramgofuncy.channel.sent.countcountergofuncy.channel.sent.durationhistogram
Configuration
Environment variables:
OTEL_ENABLED: enable telemetryGOFUNCY_CHANNEL_VALUE_EVENTS_ENABLED: creates a span event for every value sent into the channelGOFUNCY_CHANNEL_VALUE_ATTRIBUTE_ENABLED: adds the json dump of the data to the span event
Usage
From:
package main
func main() {
go func() {
numbers, err := GenerateNumbers(5)
if err != nil {
panic(err)
}
}()
}
To:
package main
import (
"github.com/foomo/gofuncy"
)
func main() {
errChan := gofuncy.Go(func(ctx context.Context) error {
numbers, err := GenerateNumbers(5)
return err
})
if err := <-errChan; err != nil {
panic(err)
}
}
How to Contribute
Make a pull request...
License
Distributed under MIT License, please see license file within the code for more details.