mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Replace uber-go/multierr with errors.Join (#10912)
This commit is contained in:
parent
d81f524cce
commit
a3b01cd05f
@ -2,6 +2,7 @@ package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strconv"
|
||||
@ -16,7 +17,6 @@ import (
|
||||
"github.com/ipfs/kubo/core/coreiface/tests"
|
||||
"github.com/ipfs/kubo/test/cli/harness"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
type NodeProvider struct{}
|
||||
@ -91,7 +91,7 @@ func (np NodeProvider) MakeAPISwarm(t *testing.T, ctx context.Context, fullIdent
|
||||
|
||||
wg.Wait()
|
||||
|
||||
return apis, multierr.Combine(errs...)
|
||||
return apis, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func TestHttpApi(t *testing.T) {
|
||||
|
||||
@ -44,7 +44,6 @@ import (
|
||||
manet "github.com/multiformats/go-multiaddr/net"
|
||||
prometheus "github.com/prometheus/client_golang/prometheus"
|
||||
promauto "github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -725,14 +724,17 @@ take effect.
|
||||
|
||||
// collect long-running errors and block for shutdown
|
||||
// TODO(cryptix): our fuse currently doesn't follow this pattern for graceful shutdown
|
||||
var errs error
|
||||
var errs []error
|
||||
for err := range merge(apiErrc, gwErrc, gcErrc, p2pGwErrc, pluginErrc, unmountErrc) {
|
||||
if err != nil {
|
||||
errs = multierr.Append(errs, err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
if len(errs) != 0 {
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
|
||||
return errs
|
||||
return nil
|
||||
}
|
||||
|
||||
// serveHTTPApi collects options, creates listener, prints status message and starts serving requests.
|
||||
|
||||
2
go.mod
2
go.mod
@ -83,7 +83,6 @@ require (
|
||||
go.opentelemetry.io/otel/trace v1.37.0
|
||||
go.uber.org/dig v1.19.0
|
||||
go.uber.org/fx v1.24.0
|
||||
go.uber.org/multierr v1.11.0
|
||||
go.uber.org/zap v1.27.0
|
||||
golang.org/x/crypto v0.41.0
|
||||
golang.org/x/exp v0.0.0-20250811191247-51f88131bc50
|
||||
@ -247,6 +246,7 @@ require (
|
||||
go.opentelemetry.io/otel/metric v1.37.0 // indirect
|
||||
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
|
||||
go.uber.org/mock v0.5.2 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap/exp v0.3.0 // indirect
|
||||
go4.org v0.0.0-20230225012048-214862532bf5 // indirect
|
||||
golang.org/x/net v0.43.0 // indirect
|
||||
|
||||
@ -2,11 +2,10 @@ package migrations
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -49,23 +48,23 @@ func NewMultiFetcher(f ...Fetcher) *MultiFetcher {
|
||||
|
||||
// Fetch attempts to fetch the file at each of its fetchers until one succeeds.
|
||||
func (f *MultiFetcher) Fetch(ctx context.Context, ipfsPath string) ([]byte, error) {
|
||||
var errs error
|
||||
var errs []error
|
||||
for _, fetcher := range f.fetchers {
|
||||
out, err := fetcher.Fetch(ctx, ipfsPath)
|
||||
if err == nil {
|
||||
return out, nil
|
||||
}
|
||||
fmt.Printf("Error fetching: %s\n", err.Error())
|
||||
errs = multierr.Append(errs, err)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return nil, errs
|
||||
return nil, errors.Join(errs...)
|
||||
}
|
||||
|
||||
func (f *MultiFetcher) Close() error {
|
||||
var errs error
|
||||
for _, fetcher := range f.fetchers {
|
||||
if err := fetcher.Close(); err != nil {
|
||||
errs = multierr.Append(errs, err)
|
||||
errs = errors.Join(errs, err)
|
||||
}
|
||||
}
|
||||
return errs
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
"github.com/libp2p/go-libp2p/core/routing"
|
||||
"github.com/multiformats/go-multihash"
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -124,7 +123,7 @@ func (c *Composer) Bootstrap(ctx context.Context) error {
|
||||
errgv := c.GetValueRouter.Bootstrap(ctx)
|
||||
errpv := c.PutValueRouter.Bootstrap(ctx)
|
||||
errp := c.ProvideRouter.Bootstrap(ctx)
|
||||
err := multierr.Combine(errfp, errfps, errgv, errpv, errp)
|
||||
err := errors.Join(errfp, errfps, errgv, errpv, errp)
|
||||
if err != nil {
|
||||
log.Debug("composer: calling bootstrap error: ", err)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user