mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-18 13:18:26 +02:00
chore(deps): update dependency golangci/golangci-lint to v2.7.2 (#3254)
* chore(deps): update dependency golangci/golangci-lint to v2.7.2 * chore(linter): fix gocritic deprecation message issue Signed-off-by: Jan Larwig <jan@larwig.com> * chore(lint): fix var-naming: avoid package names that conflict with Go standard library package names (revive) Signed-off-by: Jan Larwig <jan@larwig.com> --------- Signed-off-by: Jan Larwig <jan@larwig.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
co-authored by
Jan Larwig
parent
6a0d821df8
commit
854a74793b
@@ -0,0 +1,35 @@
|
||||
package proxyhttp
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// NewServerGroup creates a new Server to start and gracefully stop a collection
|
||||
// of Servers.
|
||||
func NewServerGroup(servers ...Server) Server {
|
||||
return &serverGroup{
|
||||
servers: servers,
|
||||
}
|
||||
}
|
||||
|
||||
// serverGroup manages the starting and graceful shutdown of a collection of
|
||||
// servers.
|
||||
type serverGroup struct {
|
||||
servers []Server
|
||||
}
|
||||
|
||||
// Start runs the servers in the server group.
|
||||
func (s *serverGroup) Start(ctx context.Context) error {
|
||||
g, groupCtx := errgroup.WithContext(ctx)
|
||||
|
||||
for _, server := range s.servers {
|
||||
srv := server
|
||||
g.Go(func() error {
|
||||
return srv.Start(groupCtx)
|
||||
})
|
||||
}
|
||||
|
||||
return g.Wait()
|
||||
}
|
||||
Reference in New Issue
Block a user