fix: errs handle.

pull/2100/head
Gordon 2 years ago
parent 37e773deeb
commit 05c8d3dac3

@ -16,7 +16,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0 github.com/mitchellh/mapstructure v1.5.0
github.com/openimsdk/localcache v0.0.1 github.com/openimsdk/localcache v0.0.1
github.com/openimsdk/protocol v0.0.58-google github.com/openimsdk/protocol v0.0.58-google
github.com/openimsdk/tools v0.0.46-alpha.16 github.com/openimsdk/tools v0.0.46-alpha.16.0.20240322040503-5ee151e04e7d
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.18.0 github.com/prometheus/client_golang v1.18.0
github.com/sirupsen/logrus v1.9.3 // indirect github.com/sirupsen/logrus v1.9.3 // indirect

@ -272,6 +272,8 @@ github.com/openimsdk/protocol v0.0.58-google h1:cGNUVaXO9LqcFgIb4NvrtEOrv0spGeco
github.com/openimsdk/protocol v0.0.58-google/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8= github.com/openimsdk/protocol v0.0.58-google/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
github.com/openimsdk/tools v0.0.46-alpha.16 h1:4ouPoTrCuyREF1UPBaka+Oge4x0XsICfNMoGxJuziKU= github.com/openimsdk/tools v0.0.46-alpha.16 h1:4ouPoTrCuyREF1UPBaka+Oge4x0XsICfNMoGxJuziKU=
github.com/openimsdk/tools v0.0.46-alpha.16/go.mod h1:hMH6pHDVhOXjA8NQ25P7mOtfRXb5lsPAv/uUDR8342Y= github.com/openimsdk/tools v0.0.46-alpha.16/go.mod h1:hMH6pHDVhOXjA8NQ25P7mOtfRXb5lsPAv/uUDR8342Y=
github.com/openimsdk/tools v0.0.46-alpha.16.0.20240322040503-5ee151e04e7d h1:XqhSyp3iHMSzUVRFWpoentayDfteybGHW7wT8WuvVEg=
github.com/openimsdk/tools v0.0.46-alpha.16.0.20240322040503-5ee151e04e7d/go.mod h1:Czxh+12vxUMypTIDZBHcTHwYL6o+DGMrC1ZmHqAk/tc=
github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo=
github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ= github.com/pelletier/go-toml/v2 v2.0.8 h1:0ctb6s9mE31h0/lhu+J6OPmVeDxJn+kYnJc2jZR9tGQ=
github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4= github.com/pelletier/go-toml/v2 v2.0.8/go.mod h1:vuYfssBdrU2XDZ9bYydBu6t+6a6PYNcZljzZR9VXg+4=

@ -16,7 +16,6 @@ package startrpc
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -161,7 +160,7 @@ func gracefulStopWithCtx(ctx context.Context, f func()) error {
}() }()
select { select {
case <-ctx.Done(): case <-ctx.Done():
return errs.Wrap(errors.New("timeout, ctx graceful stop")) return errs.New("timeout, ctx graceful stop")
case <-done: case <-done:
return nil return nil
} }

@ -20,8 +20,8 @@ import (
"crypto/md5" "crypto/md5"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"github.com/openimsdk/tools/errs"
"io" "io"
"log" "log"
"net/http" "net/http"
@ -256,10 +256,10 @@ func (m *Manage) RunTask(ctx context.Context, task Task) (string, error) {
func (m *Manage) partSize(size int64) (int64, error) { func (m *Manage) partSize(size int64) (int64, error) {
if size <= 0 { if size <= 0 {
return 0, errors.New("size must be greater than 0") return 0, errs.New("size must be greater than 0")
} }
if size > m.partLimit.MaxPartSize*int64(m.partLimit.MaxNumSize) { if size > m.partLimit.MaxPartSize*int64(m.partLimit.MaxNumSize) {
return 0, fmt.Errorf("size must be less than %db", m.partLimit.MaxPartSize*int64(m.partLimit.MaxNumSize)) return 0, errs.New("size must be less than", "size", m.partLimit.MaxPartSize*int64(m.partLimit.MaxNumSize))
} }
if size <= m.partLimit.MinPartSize*int64(m.partLimit.MaxNumSize) { if size <= m.partLimit.MinPartSize*int64(m.partLimit.MaxNumSize) {
return m.partLimit.MinPartSize, nil return m.partLimit.MinPartSize, nil

Loading…
Cancel
Save