mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 20:32:13 +01:00
process load balancing: broken but in progress
This commit is contained in:
6
internal/pkg/xerrgroup/doc.go
Normal file
6
internal/pkg/xerrgroup/doc.go
Normal file
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
Package xerrgroup helps running
|
||||
many functions simultaneously and wait until
|
||||
execution has completed or an error is encountered.
|
||||
*/
|
||||
package xerrgroup
|
||||
20
internal/pkg/xerrgroup/xerrgroup.go
Normal file
20
internal/pkg/xerrgroup/xerrgroup.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package xerrgroup
|
||||
|
||||
import (
|
||||
"github.com/thecodingmachine/gotenberg/internal/pkg/xerror"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// Run runs all functions simultaneously and wait until
|
||||
// execution has completed or an error is encountered.
|
||||
func Run(fn ...func() error) error {
|
||||
const op string = "xerrgroup.Run"
|
||||
eg := errgroup.Group{}
|
||||
for _, f := range fn {
|
||||
eg.Go(f)
|
||||
}
|
||||
if err := eg.Wait(); err != nil {
|
||||
return xerror.New(op, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user