feat: rewrite interface{} to any (#1419)
Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
parent
0222649b88
commit
a2511cb945
|
|
@ -44,8 +44,8 @@ func (r *RateLimit) UnmarshalYAML(node *yaml.Node) error {
|
|||
return r.unmarshal(yaml.Unmarshal, []byte(node.Value))
|
||||
}
|
||||
|
||||
func (r *RateLimit) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
|
||||
var v interface{}
|
||||
func (r *RateLimit) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
|
||||
var v any
|
||||
if err := unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ type Duration struct {
|
|||
}
|
||||
|
||||
func (d *Duration) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -81,7 +81,7 @@ func (d *Duration) UnmarshalJSON(b []byte) error {
|
|||
}
|
||||
|
||||
func (d *Duration) UnmarshalYAML(node *yaml.Node) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
switch node.Kind {
|
||||
case yaml.ScalarNode:
|
||||
switch node.Tag {
|
||||
|
|
@ -106,7 +106,7 @@ func (d *Duration) UnmarshalYAML(node *yaml.Node) error {
|
|||
return d.unmarshal(v)
|
||||
}
|
||||
|
||||
func (d *Duration) unmarshal(v interface{}) error {
|
||||
func (d *Duration) unmarshal(v any) error {
|
||||
switch value := v.(type) {
|
||||
case float64:
|
||||
d.Duration = time.Duration(value)
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ func newManagerClient(client managerclient.Client, hostOption HostOption) intern
|
|||
}
|
||||
}
|
||||
|
||||
func (mc *managerClient) Get() (interface{}, error) {
|
||||
func (mc *managerClient) Get() (any, error) {
|
||||
listSchedulersResp, err := mc.ListSchedulers(&manager.ListSchedulersRequest{
|
||||
SourceType: manager.SourceType_PEER_SOURCE,
|
||||
HostName: mc.hostOption.Hostname,
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ type ProxyOption struct {
|
|||
}
|
||||
|
||||
func (p *ProxyOption) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -278,7 +278,7 @@ func (p *ProxyOption) UnmarshalJSON(b []byte) error {
|
|||
return err
|
||||
}
|
||||
return nil
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
if err := p.unmarshal(json.Unmarshal, b); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -305,11 +305,11 @@ func (p *ProxyOption) UnmarshalYAML(node *yaml.Node) error {
|
|||
}
|
||||
return nil
|
||||
case yaml.MappingNode:
|
||||
var m = make(map[string]interface{})
|
||||
var m = make(map[string]any)
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
var (
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
)
|
||||
if err := node.Content[i].Decode(&key); err != nil {
|
||||
return err
|
||||
|
|
@ -334,7 +334,7 @@ func (p *ProxyOption) UnmarshalYAML(node *yaml.Node) error {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
|
||||
func (p *ProxyOption) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
|
||||
pt := struct {
|
||||
ListenOption `mapstructure:",squash" yaml:",inline"`
|
||||
BasicAuth *BasicAuth `mapstructure:"basicAuth" yaml:"basicAuth"`
|
||||
|
|
@ -412,7 +412,7 @@ type TCPListenPortRange struct {
|
|||
}
|
||||
|
||||
func (t *TCPListenPortRange) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -420,10 +420,10 @@ func (t *TCPListenPortRange) UnmarshalJSON(b []byte) error {
|
|||
}
|
||||
|
||||
func (t *TCPListenPortRange) UnmarshalYAML(node *yaml.Node) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
switch node.Kind {
|
||||
case yaml.MappingNode:
|
||||
var m = make(map[string]interface{})
|
||||
var m = make(map[string]any)
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
var (
|
||||
key string
|
||||
|
|
@ -448,7 +448,7 @@ func (t *TCPListenPortRange) UnmarshalYAML(node *yaml.Node) error {
|
|||
return t.unmarshal(v)
|
||||
}
|
||||
|
||||
func (t *TCPListenPortRange) unmarshal(v interface{}) error {
|
||||
func (t *TCPListenPortRange) unmarshal(v any) error {
|
||||
switch value := v.(type) {
|
||||
case int:
|
||||
t.Start = value
|
||||
|
|
@ -456,7 +456,7 @@ func (t *TCPListenPortRange) unmarshal(v interface{}) error {
|
|||
case float64:
|
||||
t.Start = int(value)
|
||||
return nil
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
if s, ok := value["start"]; ok {
|
||||
switch start := s.(type) {
|
||||
case float64:
|
||||
|
|
@ -638,11 +638,11 @@ type URL struct {
|
|||
|
||||
// UnmarshalJSON implements json.Unmarshaler.
|
||||
func (u *URL) UnmarshalJSON(b []byte) error {
|
||||
return u.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
|
||||
return u.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler.
|
||||
func (u *URL) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (u *URL) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
return u.unmarshal(unmarshal)
|
||||
}
|
||||
|
||||
|
|
@ -652,11 +652,11 @@ func (u *URL) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaller to print the url.
|
||||
func (u *URL) MarshalYAML() (interface{}, error) {
|
||||
func (u *URL) MarshalYAML() (any, error) {
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
func (u *URL) unmarshal(unmarshal func(interface{}) error) error {
|
||||
func (u *URL) unmarshal(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
|
@ -680,11 +680,11 @@ type CertPool struct {
|
|||
|
||||
// UnmarshalJSON implements json.Unmarshaler.
|
||||
func (cp *CertPool) UnmarshalJSON(b []byte) error {
|
||||
return cp.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
|
||||
return cp.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
|
||||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler.
|
||||
func (cp *CertPool) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (cp *CertPool) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
return cp.unmarshal(unmarshal)
|
||||
}
|
||||
|
||||
|
|
@ -694,11 +694,11 @@ func (cp *CertPool) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaller to print the cert pool.
|
||||
func (cp *CertPool) MarshalYAML() (interface{}, error) {
|
||||
func (cp *CertPool) MarshalYAML() (any, error) {
|
||||
return cp.Files, nil
|
||||
}
|
||||
|
||||
func (cp *CertPool) unmarshal(unmarshal func(interface{}) error) error {
|
||||
func (cp *CertPool) unmarshal(unmarshal func(any) error) error {
|
||||
if err := unmarshal(&cp.Files); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -776,16 +776,16 @@ func NewRegexp(exp string) (*Regexp, error) {
|
|||
}
|
||||
|
||||
// UnmarshalYAML implements yaml.Unmarshaler.
|
||||
func (r *Regexp) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||||
func (r *Regexp) UnmarshalYAML(unmarshal func(any) error) error {
|
||||
return r.unmarshal(unmarshal)
|
||||
}
|
||||
|
||||
// UnmarshalJSON implements json.Unmarshaler.
|
||||
func (r *Regexp) UnmarshalJSON(b []byte) error {
|
||||
return r.unmarshal(func(v interface{}) error { return json.Unmarshal(b, v) })
|
||||
return r.unmarshal(func(v any) error { return json.Unmarshal(b, v) })
|
||||
}
|
||||
|
||||
func (r *Regexp) unmarshal(unmarshal func(interface{}) error) error {
|
||||
func (r *Regexp) unmarshal(unmarshal func(any) error) error {
|
||||
var s string
|
||||
if err := unmarshal(&s); err != nil {
|
||||
return err
|
||||
|
|
@ -803,7 +803,7 @@ func (r *Regexp) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
// MarshalYAML implements yaml.Marshaller to print the regexp.
|
||||
func (r *Regexp) MarshalYAML() (interface{}, error) {
|
||||
func (r *Regexp) MarshalYAML() (any, error) {
|
||||
return r.String(), nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ func Test_AllUnmarshalYAML(t *testing.T) {
|
|||
assert := testifyassert.New(t)
|
||||
var cases = []struct {
|
||||
text string
|
||||
target interface{}
|
||||
target any
|
||||
}{
|
||||
{
|
||||
text: `
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ func (ts *testSpec) runConductorTest(assert *testifyassert.Assertions, require *
|
|||
assert.True(success, "task should success")
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
ptm.runningPeerTasks.Range(func(key, value interface{}) bool {
|
||||
ptm.runningPeerTasks.Range(func(key, value any) bool {
|
||||
noRunningTask = false
|
||||
return false
|
||||
})
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ func (poller *pieceTaskPoller) getPieceTasksByPeer(
|
|||
count int
|
||||
ptc = poller.peerTaskConductor
|
||||
)
|
||||
p, _, err := retry.Run(ptc.ctx, func() (interface{}, bool, error) {
|
||||
p, _, err := retry.Run(ptc.ctx, func() (any, bool, error) {
|
||||
// GetPieceTasks must be fast, so short time out is okay
|
||||
ctx, cancel := context.WithTimeout(ptc.ctx, 4*time.Second)
|
||||
defer cancel()
|
||||
|
|
|
|||
|
|
@ -159,17 +159,17 @@ func getEnv(w http.ResponseWriter, r *http.Request) {
|
|||
// ensureStringKey recursively ensures all maps in the given interface are string,
|
||||
// to make the result marshalable by json. This is meant to be used with viper
|
||||
// settings, so only maps and slices are handled.
|
||||
func ensureStringKey(obj interface{}) interface{} {
|
||||
func ensureStringKey(obj any) any {
|
||||
rt, rv := reflect.TypeOf(obj), reflect.ValueOf(obj)
|
||||
switch rt.Kind() {
|
||||
case reflect.Map:
|
||||
res := make(map[string]interface{})
|
||||
res := make(map[string]any)
|
||||
for _, k := range rv.MapKeys() {
|
||||
res[fmt.Sprintf("%v", k.Interface())] = ensureStringKey(rv.MapIndex(k).Interface())
|
||||
}
|
||||
return res
|
||||
case reflect.Slice:
|
||||
res := make([]interface{}, rv.Len())
|
||||
res := make([]any, rv.Len())
|
||||
for i := 0; i < rv.Len(); i++ {
|
||||
res[i] = ensureStringKey(rv.Index(i).Interface())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -775,7 +775,7 @@ func (s *storageManager) TryGC() (bool, error) {
|
|||
// FIXME gc subtask
|
||||
var markedTasks []PeerTaskMetadata
|
||||
var totalNotMarkedSize int64
|
||||
s.tasks.Range(func(key, task interface{}) bool {
|
||||
s.tasks.Range(func(key, task any) bool {
|
||||
if task.(Reclaimer).CanReclaim() {
|
||||
task.(Reclaimer).MarkReclaim()
|
||||
markedTasks = append(markedTasks, key.(PeerTaskMetadata))
|
||||
|
|
@ -804,7 +804,7 @@ func (s *storageManager) TryGC() (bool, error) {
|
|||
}
|
||||
logger.Infof("quota threshold reached, start gc oldest task, size: %d bytes", bytesExceed)
|
||||
var tasks []*localTaskStore
|
||||
s.tasks.Range(func(key, val interface{}) bool {
|
||||
s.tasks.Range(func(key, val any) bool {
|
||||
// skip reclaimed task
|
||||
task, ok := val.(*localTaskStore)
|
||||
if !ok { // skip subtask
|
||||
|
|
@ -911,7 +911,7 @@ func (s *storageManager) CleanUp() {
|
|||
}
|
||||
|
||||
func (s *storageManager) forceGC() (bool, error) {
|
||||
s.tasks.Range(func(key, task interface{}) bool {
|
||||
s.tasks.Range(func(key, task any) bool {
|
||||
meta := key.(PeerTaskMetadata)
|
||||
err := s.deleteTask(meta)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ import (
|
|||
|
||||
// InitCobra initializes flags binding and common sub cmds.
|
||||
// config is a pointer to configuration struct.
|
||||
func InitCobra(cmd *cobra.Command, useConfigFile bool, config interface{}) {
|
||||
func InitCobra(cmd *cobra.Command, useConfigFile bool, config any) {
|
||||
rootName := cmd.Root().Name()
|
||||
cobra.OnInitialize(func() { initConfig(useConfigFile, rootName, config) })
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ func SetupQuitSignalHandler(handler func()) {
|
|||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig(useConfigFile bool, name string, config interface{}) {
|
||||
func initConfig(useConfigFile bool, name string, config any) {
|
||||
// Use config file and read once.
|
||||
if useConfigFile {
|
||||
cfgFile := viper.GetString("config")
|
||||
|
|
@ -187,7 +187,7 @@ func initConfig(useConfigFile bool, name string, config interface{}) {
|
|||
}
|
||||
|
||||
func initDecoderConfig(dc *mapstructure.DecoderConfig) {
|
||||
dc.DecodeHook = mapstructure.ComposeDecodeHookFunc(func(from, to reflect.Type, v interface{}) (interface{}, error) {
|
||||
dc.DecodeHook = mapstructure.ComposeDecodeHookFunc(func(from, to reflect.Type, v any) (any, error) {
|
||||
switch to {
|
||||
case reflect.TypeOf(unit.B),
|
||||
reflect.TypeOf(dfnet.NetAddr{}),
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func New(code base.Code, msg string) *DfError {
|
|||
}
|
||||
}
|
||||
|
||||
func Newf(code base.Code, format string, a ...interface{}) *DfError {
|
||||
func Newf(code base.Code, format string, a ...any) *DfError {
|
||||
return &DfError{
|
||||
Code: code,
|
||||
Message: fmt.Sprintf(format, a...),
|
||||
|
|
|
|||
|
|
@ -107,10 +107,10 @@ func SetJobLogger(log *zap.SugaredLogger) {
|
|||
}
|
||||
|
||||
type SugaredLoggerOnWith struct {
|
||||
withArgs []interface{}
|
||||
withArgs []any
|
||||
}
|
||||
|
||||
func With(args ...interface{}) *SugaredLoggerOnWith {
|
||||
func With(args ...any) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: args,
|
||||
}
|
||||
|
|
@ -118,130 +118,130 @@ func With(args ...interface{}) *SugaredLoggerOnWith {
|
|||
|
||||
func WithHostID(hostID string) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: []interface{}{"hostID", hostID},
|
||||
withArgs: []any{"hostID", hostID},
|
||||
}
|
||||
}
|
||||
|
||||
func WithTaskID(taskID string) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: []interface{}{"taskID", taskID},
|
||||
withArgs: []any{"taskID", taskID},
|
||||
}
|
||||
}
|
||||
|
||||
func WithTaskAndPeerID(taskID, peerID string) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: []interface{}{"taskID", taskID, "peerID", peerID},
|
||||
withArgs: []any{"taskID", taskID, "peerID", peerID},
|
||||
}
|
||||
}
|
||||
|
||||
func WithTaskIDAndURL(taskID, url string) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: []interface{}{"taskID", taskID, "url", url},
|
||||
withArgs: []any{"taskID", taskID, "url", url},
|
||||
}
|
||||
}
|
||||
|
||||
func WithHostnameAndIP(hostname, ip string) *SugaredLoggerOnWith {
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: []interface{}{"hostname", hostname, "ip", ip},
|
||||
withArgs: []any{"hostname", hostname, "ip", ip},
|
||||
}
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) With(args ...interface{}) *SugaredLoggerOnWith {
|
||||
func (log *SugaredLoggerOnWith) With(args ...any) *SugaredLoggerOnWith {
|
||||
args = append(args, log.withArgs...)
|
||||
return &SugaredLoggerOnWith{
|
||||
withArgs: args,
|
||||
}
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Infof(template string, args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Infof(template string, args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.InfoLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Infow(fmt.Sprintf(template, args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Info(args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Info(args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.InfoLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Infow(fmt.Sprint(args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Warnf(template string, args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Warnf(template string, args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.WarnLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Warnw(fmt.Sprintf(template, args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Warn(args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Warn(args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.WarnLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Warnw(fmt.Sprint(args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Errorf(template string, args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Errorf(template string, args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.ErrorLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Errorw(fmt.Sprintf(template, args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Error(args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Error(args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.ErrorLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Errorw(fmt.Sprint(args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Debugf(template string, args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Debugf(template string, args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.DebugLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Debugw(fmt.Sprintf(template, args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func (log *SugaredLoggerOnWith) Debug(args ...interface{}) {
|
||||
func (log *SugaredLoggerOnWith) Debug(args ...any) {
|
||||
if !coreLogLevelEnabler.Enabled(zap.DebugLevel) {
|
||||
return
|
||||
}
|
||||
CoreLogger.Debugw(fmt.Sprint(args...), log.withArgs...)
|
||||
}
|
||||
|
||||
func Infof(template string, args ...interface{}) {
|
||||
func Infof(template string, args ...any) {
|
||||
CoreLogger.Infof(template, args...)
|
||||
}
|
||||
|
||||
func Info(args ...interface{}) {
|
||||
func Info(args ...any) {
|
||||
CoreLogger.Info(args...)
|
||||
}
|
||||
|
||||
func Warnf(template string, args ...interface{}) {
|
||||
func Warnf(template string, args ...any) {
|
||||
CoreLogger.Warnf(template, args...)
|
||||
}
|
||||
|
||||
func Warn(args ...interface{}) {
|
||||
func Warn(args ...any) {
|
||||
CoreLogger.Warn(args...)
|
||||
}
|
||||
|
||||
func Errorf(template string, args ...interface{}) {
|
||||
func Errorf(template string, args ...any) {
|
||||
CoreLogger.Errorf(template, args...)
|
||||
}
|
||||
|
||||
func Error(args ...interface{}) {
|
||||
func Error(args ...any) {
|
||||
CoreLogger.Error(args...)
|
||||
}
|
||||
|
||||
func Debugf(template string, args ...interface{}) {
|
||||
func Debugf(template string, args ...any) {
|
||||
CoreLogger.Debugf(template, args...)
|
||||
}
|
||||
|
||||
func Fatalf(template string, args ...interface{}) {
|
||||
func Fatalf(template string, args ...any) {
|
||||
CoreLogger.Fatalf(template, args...)
|
||||
}
|
||||
|
||||
func Fatal(args ...interface{}) {
|
||||
func Fatal(args ...any) {
|
||||
CoreLogger.Fatal(args...)
|
||||
}
|
||||
|
||||
|
|
@ -250,27 +250,27 @@ type zapGrpc struct {
|
|||
verbose int
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Infoln(args ...interface{}) {
|
||||
func (z *zapGrpc) Infoln(args ...any) {
|
||||
z.SugaredLogger.Info(args...)
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Warning(args ...interface{}) {
|
||||
func (z *zapGrpc) Warning(args ...any) {
|
||||
z.SugaredLogger.Warn(args...)
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Warningln(args ...interface{}) {
|
||||
func (z *zapGrpc) Warningln(args ...any) {
|
||||
z.SugaredLogger.Warn(args...)
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Warningf(format string, args ...interface{}) {
|
||||
func (z *zapGrpc) Warningf(format string, args ...any) {
|
||||
z.SugaredLogger.Warnf(format, args...)
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Errorln(args ...interface{}) {
|
||||
func (z *zapGrpc) Errorln(args ...any) {
|
||||
z.SugaredLogger.Error(args...)
|
||||
}
|
||||
|
||||
func (z *zapGrpc) Fatalln(args ...interface{}) {
|
||||
func (z *zapGrpc) Fatalln(args ...any) {
|
||||
z.SugaredLogger.Fatal(args...)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ const (
|
|||
PluginTypeScheduler = PluginType("scheduler")
|
||||
)
|
||||
|
||||
type PluginInitFunc func(option map[string]string) (plugin interface{}, meta map[string]string, err error)
|
||||
type PluginInitFunc func(option map[string]string) (plugin any, meta map[string]string, err error)
|
||||
|
||||
func Load(dir string, typ PluginType, name string, option map[string]string) (interface{}, map[string]string, error) {
|
||||
func Load(dir string, typ PluginType, name string, option map[string]string) (any, map[string]string, error) {
|
||||
soName := fmt.Sprintf(PluginFormat, string(typ), name)
|
||||
p, err := plugin.Open(path.Join(dir, soName))
|
||||
if err != nil {
|
||||
|
|
@ -63,7 +63,7 @@ func Load(dir string, typ PluginType, name string, option map[string]string) (in
|
|||
}
|
||||
|
||||
// FIXME when use symbol.(PluginInitFunc), ok is always false
|
||||
f, ok := symbol.(func(option map[string]string) (plugin interface{}, meta map[string]string, err error))
|
||||
f, ok := symbol.(func(option map[string]string) (plugin any, meta map[string]string, err error))
|
||||
if !ok {
|
||||
return nil, nil, errors.New("invalid plugin init function signature")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ const (
|
|||
)
|
||||
|
||||
type strategy interface {
|
||||
Unmarshal(rawVal interface{}) error
|
||||
Unmarshal(rawVal any) error
|
||||
}
|
||||
|
||||
type Dynconfig struct {
|
||||
|
|
@ -154,7 +154,7 @@ func (d *Dynconfig) validate() error {
|
|||
|
||||
// Unmarshal unmarshals the config into a Struct. Make sure that the tags
|
||||
// on the fields of the structure are properly set.
|
||||
func (d *Dynconfig) Unmarshal(rawVal interface{}) error {
|
||||
func (d *Dynconfig) Unmarshal(rawVal any) error {
|
||||
return d.strategy.Unmarshal(rawVal)
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ type DecoderConfigOption func(*mapstructure.DecoderConfig)
|
|||
|
||||
// defaultDecoderConfig returns default mapstructure.DecoderConfig with support
|
||||
// of time.Duration values & string slices
|
||||
func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
||||
func defaultDecoderConfig(output any) *mapstructure.DecoderConfig {
|
||||
c := &mapstructure.DecoderConfig{
|
||||
Metadata: nil,
|
||||
Result: output,
|
||||
|
|
@ -178,7 +178,7 @@ func defaultDecoderConfig(output interface{}) *mapstructure.DecoderConfig {
|
|||
}
|
||||
|
||||
// A wrapper around mapstructure.Decode that mimics the WeakDecode functionality
|
||||
func decode(input interface{}, config *mapstructure.DecoderConfig) error {
|
||||
func decode(input any, config *mapstructure.DecoderConfig) error {
|
||||
decoder, err := mapstructure.NewDecoder(config)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func newDynconfigLocal(path string) (*dynconfigLocal, error) {
|
|||
|
||||
// Unmarshal unmarshals the config into a Struct. Make sure that the tags
|
||||
// on the fields of the structure are properly set.
|
||||
func (d *dynconfigLocal) Unmarshal(rawVal interface{}) error {
|
||||
func (d *dynconfigLocal) Unmarshal(rawVal any) error {
|
||||
b, err := os.ReadFile(d.filepath)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ func newDynconfigManager(expire time.Duration, cachePath string, client ManagerC
|
|||
}
|
||||
|
||||
// Get dynamic config
|
||||
func (d *dynconfigManager) get() (interface{}, error) {
|
||||
func (d *dynconfigManager) get() (any, error) {
|
||||
// Cache has not expired
|
||||
dynconfig, _, found := d.cache.GetWithExpiration(defaultCacheKey)
|
||||
if found {
|
||||
|
|
@ -73,7 +73,7 @@ func (d *dynconfigManager) get() (interface{}, error) {
|
|||
|
||||
// Unmarshal unmarshals the config into a Struct. Make sure that the tags
|
||||
// on the fields of the structure are properly set.
|
||||
func (d *dynconfigManager) Unmarshal(rawVal interface{}) error {
|
||||
func (d *dynconfigManager) Unmarshal(rawVal any) error {
|
||||
dynconfig, err := d.get()
|
||||
if err != nil {
|
||||
return errors.New("can't find the cached data")
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
sleep func()
|
||||
cleanFileCache func(t *testing.T)
|
||||
mock func(m *mocks.MockManagerClientMockRecorder)
|
||||
expect func(t *testing.T, data interface{})
|
||||
expect func(t *testing.T, data any)
|
||||
}{
|
||||
{
|
||||
name: "unmarshals dynconfig success without file cache",
|
||||
|
|
@ -65,7 +65,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
sleep: func() {},
|
||||
cleanFileCache: func(t *testing.T) {},
|
||||
mock: func(m *mocks.MockManagerClientMockRecorder) {
|
||||
var d map[string]interface{}
|
||||
var d map[string]any
|
||||
if err := mapstructure.Decode(TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
Name: schedulerName,
|
||||
|
|
@ -76,7 +76,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
|
||||
m.Get().Return(d, nil).AnyTimes()
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := assert.New(t)
|
||||
var d TestDynconfig
|
||||
if err := mapstructure.Decode(data, &d); err != nil {
|
||||
|
|
@ -107,7 +107,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
}
|
||||
},
|
||||
mock: func(m *mocks.MockManagerClientMockRecorder) {
|
||||
var d map[string]interface{}
|
||||
var d map[string]any
|
||||
if err := mapstructure.Decode(TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
Name: schedulerName,
|
||||
|
|
@ -118,7 +118,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
|
||||
m.Get().Return(d, nil).Times(1)
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualValues(data, TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
|
|
@ -144,7 +144,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
}
|
||||
},
|
||||
mock: func(m *mocks.MockManagerClientMockRecorder) {
|
||||
var d map[string]interface{}
|
||||
var d map[string]any
|
||||
if err := mapstructure.Decode(TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
Name: schedulerName,
|
||||
|
|
@ -156,7 +156,7 @@ func TestDynconfigUnmarshal_ManagerSourceType(t *testing.T) {
|
|||
m.Get().Return(d, nil).Times(1)
|
||||
m.Get().Return(nil, errors.New("manager serivce error")).Times(1)
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualValues(data, TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
|
|
@ -205,7 +205,7 @@ func TestDynconfigUnmarshal_LocalSourceType(t *testing.T) {
|
|||
dynconfig TestDynconfig
|
||||
configPath string
|
||||
sleep func()
|
||||
expect func(t *testing.T, data interface{})
|
||||
expect func(t *testing.T, data any)
|
||||
}{
|
||||
{
|
||||
name: "unmarshals dynconfig success with local file",
|
||||
|
|
@ -217,7 +217,7 @@ func TestDynconfigUnmarshal_LocalSourceType(t *testing.T) {
|
|||
},
|
||||
configPath: configPath,
|
||||
sleep: func() {},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := assert.New(t)
|
||||
var d TestDynconfig
|
||||
if err := mapstructure.Decode(data, &d); err != nil {
|
||||
|
|
@ -243,7 +243,7 @@ func TestDynconfigUnmarshal_LocalSourceType(t *testing.T) {
|
|||
sleep: func() {
|
||||
time.Sleep(30 * time.Millisecond)
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualValues(data, TestDynconfig{
|
||||
Scheduler: SchedulerOption{
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@ package dynconfig
|
|||
|
||||
// managerClient is a client of manager
|
||||
type ManagerClient interface {
|
||||
Get() (interface{}, error)
|
||||
Get() (any, error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (m *Mockstrategy) EXPECT() *MockstrategyMockRecorder {
|
|||
}
|
||||
|
||||
// Unmarshal mocks base method.
|
||||
func (m *Mockstrategy) Unmarshal(rawVal interface{}) error {
|
||||
func (m *Mockstrategy) Unmarshal(rawVal any) error {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Unmarshal", rawVal)
|
||||
ret0, _ := ret[0].(error)
|
||||
|
|
|
|||
|
|
@ -34,10 +34,10 @@ func (m *MockManagerClient) EXPECT() *MockManagerClientMockRecorder {
|
|||
}
|
||||
|
||||
// Get mocks base method.
|
||||
func (m *MockManagerClient) Get() (interface{}, error) {
|
||||
func (m *MockManagerClient) Get() (any, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Get")
|
||||
ret0, _ := ret[0].(interface{})
|
||||
ret0, _ := ret[0].(any)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func ping(options *redis.Options) error {
|
|||
return client.Ping(context.Background()).Err()
|
||||
}
|
||||
|
||||
func (t *Job) RegisterJob(namedJobFuncs map[string]interface{}) error {
|
||||
func (t *Job) RegisterJob(namedJobFuncs map[string]any) error {
|
||||
return t.Server.RegisterTasks(namedJobFuncs)
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ func (t *Job) GetGroupJobState(groupUUID string) (*GroupJobState, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func MarshalRequest(v interface{}) ([]machineryv1tasks.Arg, error) {
|
||||
func MarshalRequest(v any) ([]machineryv1tasks.Arg, error) {
|
||||
b, err := json.Marshal(v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -158,7 +158,7 @@ func MarshalRequest(v interface{}) ([]machineryv1tasks.Arg, error) {
|
|||
}}, nil
|
||||
}
|
||||
|
||||
func UnmarshalResponse(data []reflect.Value, v interface{}) error {
|
||||
func UnmarshalResponse(data []reflect.Value, v any) error {
|
||||
if len(data) == 0 {
|
||||
return errors.New("empty data is not specified")
|
||||
}
|
||||
|
|
@ -169,6 +169,6 @@ func UnmarshalResponse(data []reflect.Value, v interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func UnmarshalRequest(data string, v interface{}) error {
|
||||
func UnmarshalRequest(data string, v any) error {
|
||||
return json.Unmarshal([]byte(data), v)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
func TestJobMarshal(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
value any
|
||||
expect func(t *testing.T, result []machineryv1tasks.Arg, err error)
|
||||
}{
|
||||
{
|
||||
|
|
@ -114,8 +114,8 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
data []reflect.Value
|
||||
value interface{}
|
||||
expect func(t *testing.T, result interface{}, err error)
|
||||
value any
|
||||
expect func(t *testing.T, result any, err error)
|
||||
}{
|
||||
{
|
||||
name: "unmarshal common struct",
|
||||
|
|
@ -127,7 +127,7 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
F float64 `json:"f" binding:"omitempty"`
|
||||
S string `json:"s" binding:"omitempty"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
I int64 `json:"i" binding:"omitempty"`
|
||||
|
|
@ -146,7 +146,7 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
F float64 `json:"f" binding:"omitempty"`
|
||||
S string `json:"s" binding:"omitempty"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
I int64 `json:"i" binding:"omitempty"`
|
||||
|
|
@ -163,7 +163,7 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
|
|
@ -178,7 +178,7 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
|
|
@ -191,7 +191,7 @@ func TestJobUnmarshal(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("empty data is not specified", err.Error())
|
||||
},
|
||||
|
|
@ -210,8 +210,8 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
data string
|
||||
value interface{}
|
||||
expect func(t *testing.T, result interface{}, err error)
|
||||
value any
|
||||
expect func(t *testing.T, result any, err error)
|
||||
}{
|
||||
{
|
||||
name: "unmarshal common struct",
|
||||
|
|
@ -221,7 +221,7 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
F float64 `json:"f" binding:"omitempty"`
|
||||
S string `json:"s" binding:"omitempty"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
I int64 `json:"i" binding:"omitempty"`
|
||||
|
|
@ -238,7 +238,7 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
F float64 `json:"f" binding:"omitempty"`
|
||||
S string `json:"s" binding:"omitempty"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
I int64 `json:"i" binding:"omitempty"`
|
||||
|
|
@ -253,7 +253,7 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
|
|
@ -266,7 +266,7 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(&struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
|
|
@ -279,7 +279,7 @@ func TestUnmarshalRequest(t *testing.T) {
|
|||
value: &struct {
|
||||
S []string `json:"s" binding:"required"`
|
||||
}{},
|
||||
expect: func(t *testing.T, result interface{}, err error) {
|
||||
expect: func(t *testing.T, result any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("unexpected end of JSON input", err.Error())
|
||||
},
|
||||
|
|
|
|||
|
|
@ -7,46 +7,46 @@ import (
|
|||
type MachineryLogger struct{}
|
||||
|
||||
// Print sends to logger.Info
|
||||
func (m *MachineryLogger) Print(args ...interface{}) {
|
||||
func (m *MachineryLogger) Print(args ...any) {
|
||||
logger.JobLogger.Info(args...)
|
||||
}
|
||||
|
||||
// Printf sends to logger.Infof
|
||||
func (m *MachineryLogger) Printf(format string, args ...interface{}) {
|
||||
func (m *MachineryLogger) Printf(format string, args ...any) {
|
||||
logger.JobLogger.Infof(format, args...)
|
||||
}
|
||||
|
||||
// Println sends to logger.Info
|
||||
func (m *MachineryLogger) Println(args ...interface{}) {
|
||||
func (m *MachineryLogger) Println(args ...any) {
|
||||
logger.JobLogger.Info(args...)
|
||||
}
|
||||
|
||||
// Fatal sends to logger.Fatal
|
||||
func (m *MachineryLogger) Fatal(args ...interface{}) {
|
||||
func (m *MachineryLogger) Fatal(args ...any) {
|
||||
logger.JobLogger.Fatal(args...)
|
||||
}
|
||||
|
||||
// Fatalf sends to logger.Fatalf
|
||||
func (m *MachineryLogger) Fatalf(format string, args ...interface{}) {
|
||||
func (m *MachineryLogger) Fatalf(format string, args ...any) {
|
||||
logger.JobLogger.Fatalf(format, args...)
|
||||
}
|
||||
|
||||
// Fatalln sends to logger.Fatal
|
||||
func (m *MachineryLogger) Fatalln(args ...interface{}) {
|
||||
func (m *MachineryLogger) Fatalln(args ...any) {
|
||||
logger.JobLogger.Fatal(args...)
|
||||
}
|
||||
|
||||
// Panic sends to logger.Panic
|
||||
func (m *MachineryLogger) Panic(args ...interface{}) {
|
||||
func (m *MachineryLogger) Panic(args ...any) {
|
||||
logger.JobLogger.Panic(args...)
|
||||
}
|
||||
|
||||
// Panicf sends to logger.Panic
|
||||
func (m *MachineryLogger) Panicf(format string, args ...interface{}) {
|
||||
func (m *MachineryLogger) Panicf(format string, args ...any) {
|
||||
logger.JobLogger.Panic(args...)
|
||||
}
|
||||
|
||||
// Panicln sends to logrus.Panic
|
||||
func (m *MachineryLogger) Panicln(args ...interface{}) {
|
||||
func (m *MachineryLogger) Panicln(args ...any) {
|
||||
logger.JobLogger.Panic(args...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ func TestManagerConfig_Load(t *testing.T) {
|
|||
|
||||
managerConfigYAML := &Config{}
|
||||
contentYAML, _ := os.ReadFile("./testdata/manager.yaml")
|
||||
var dataYAML map[string]interface{}
|
||||
var dataYAML map[string]any
|
||||
if err := yaml.Unmarshal(contentYAML, &dataYAML); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -129,14 +129,14 @@ func seed(cfg *config.Config, db *gorm.DB) error {
|
|||
ID: uint(1),
|
||||
},
|
||||
Name: "scheduler-cluster-1",
|
||||
Config: map[string]interface{}{
|
||||
Config: map[string]any{
|
||||
"filter_parent_limit": schedulerconfig.DefaultSchedulerFilterParentLimit,
|
||||
},
|
||||
ClientConfig: map[string]interface{}{
|
||||
ClientConfig: map[string]any{
|
||||
"load_limit": schedulerconfig.DefaultClientLoadLimit,
|
||||
"parallel_count": schedulerconfig.DefaultClientParallelCount,
|
||||
},
|
||||
Scopes: map[string]interface{}{},
|
||||
Scopes: map[string]any{},
|
||||
IsDefault: true,
|
||||
}).Error; err != nil {
|
||||
return err
|
||||
|
|
@ -154,7 +154,7 @@ func seed(cfg *config.Config, db *gorm.DB) error {
|
|||
ID: uint(1),
|
||||
},
|
||||
Name: "seed-peer-cluster-1",
|
||||
Config: map[string]interface{}{
|
||||
Config: map[string]any{
|
||||
"load_limit": schedulerconfig.DefaultSeedPeerLoadLimit,
|
||||
},
|
||||
IsDefault: true,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,6 @@ import (
|
|||
|
||||
type redisLogger struct{}
|
||||
|
||||
func (rl *redisLogger) Printf(ctx context.Context, format string, v ...interface{}) {
|
||||
func (rl *redisLogger) Printf(ctx context.Context, format string, v ...any) {
|
||||
logger.CoreLogger.Desugar().Info(fmt.Sprintf(format, v...))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ func getAuthToken(ctx context.Context, header http.Header) (string, error) {
|
|||
defer resp.Body.Close()
|
||||
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
var result map[string]interface{}
|
||||
var result map[string]any
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ func Jwt(service service.Service) (*jwt.GinJWTMiddleware, error) {
|
|||
MaxRefresh: 2 * 24 * time.Hour,
|
||||
IdentityKey: identityKey,
|
||||
|
||||
IdentityHandler: func(c *gin.Context) interface{} {
|
||||
IdentityHandler: func(c *gin.Context) any {
|
||||
claims := jwt.ExtractClaims(c)
|
||||
|
||||
id, ok := claims[identityKey]
|
||||
|
|
@ -55,7 +55,7 @@ func Jwt(service service.Service) (*jwt.GinJWTMiddleware, error) {
|
|||
return id
|
||||
},
|
||||
|
||||
Authenticator: func(c *gin.Context) (interface{}, error) {
|
||||
Authenticator: func(c *gin.Context) (any, error) {
|
||||
// Oauth2 signin
|
||||
if rawUser, ok := c.Get("user"); ok {
|
||||
user, ok := rawUser.(*model.User)
|
||||
|
|
@ -79,7 +79,7 @@ func Jwt(service service.Service) (*jwt.GinJWTMiddleware, error) {
|
|||
return user, nil
|
||||
},
|
||||
|
||||
PayloadFunc: func(data interface{}) jwt.MapClaims {
|
||||
PayloadFunc: func(data any) jwt.MapClaims {
|
||||
if user, ok := data.(*model.User); ok {
|
||||
return jwt.MapClaims{
|
||||
identityKey: user.ID,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ func Paginate(page, perPage int) func(db *gorm.DB) *gorm.DB {
|
|||
}
|
||||
|
||||
type (
|
||||
JSONMap map[string]interface{}
|
||||
JSONMap map[string]any
|
||||
Array []string
|
||||
)
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ func (a Array) Value() (driver.Value, error) {
|
|||
return string(ba), err
|
||||
}
|
||||
|
||||
func (m *JSONMap) Scan(val interface{}) error {
|
||||
func (m *JSONMap) Scan(val any) error {
|
||||
var ba []byte
|
||||
switch v := val.(type) {
|
||||
case []byte:
|
||||
|
|
@ -73,13 +73,13 @@ func (m *JSONMap) Scan(val interface{}) error {
|
|||
default:
|
||||
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", val))
|
||||
}
|
||||
t := map[string]interface{}{}
|
||||
t := map[string]any{}
|
||||
err := json.Unmarshal(ba, &t)
|
||||
*m = JSONMap(t)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *Array) Scan(val interface{}) error {
|
||||
func (a *Array) Scan(val any) error {
|
||||
var ba []byte
|
||||
switch v := val.(type) {
|
||||
case []byte:
|
||||
|
|
@ -99,7 +99,7 @@ func (m JSONMap) MarshalJSON() ([]byte, error) {
|
|||
if m == nil {
|
||||
return []byte("null"), nil
|
||||
}
|
||||
t := (map[string]interface{})(m)
|
||||
t := (map[string]any)(m)
|
||||
return json.Marshal(t)
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +112,7 @@ func (a Array) MarshalJSON() ([]byte, error) {
|
|||
}
|
||||
|
||||
func (m *JSONMap) UnmarshalJSON(b []byte) error {
|
||||
t := map[string]interface{}{}
|
||||
t := map[string]any{}
|
||||
err := json.Unmarshal(b, &t)
|
||||
*m = JSONMap(t)
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"location": "location-1",
|
||||
},
|
||||
Schedulers: []model.Scheduler{
|
||||
|
|
@ -244,7 +244,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc|idc-1",
|
||||
},
|
||||
Schedulers: []model.Scheduler{
|
||||
|
|
@ -256,7 +256,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-2|idc-3",
|
||||
},
|
||||
Schedulers: []model.Scheduler{
|
||||
|
|
@ -280,7 +280,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"net_topology": "net-topology-1",
|
||||
},
|
||||
Schedulers: []model.Scheduler{
|
||||
|
|
@ -313,7 +313,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"location": "location-1|location-2",
|
||||
"idc": "idc-1|idc-2",
|
||||
},
|
||||
|
|
@ -350,7 +350,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"location": "location-1",
|
||||
},
|
||||
SecurityGroup: model.SecurityGroup{
|
||||
|
|
@ -393,7 +393,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
},
|
||||
SecurityGroup: model.SecurityGroup{
|
||||
|
|
@ -436,7 +436,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-1",
|
||||
},
|
||||
|
|
@ -456,7 +456,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-2",
|
||||
"location": "location-1|location-2",
|
||||
},
|
||||
|
|
@ -476,7 +476,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "baz",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-2",
|
||||
"location": "location-1",
|
||||
},
|
||||
|
|
@ -512,7 +512,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-2",
|
||||
},
|
||||
|
|
@ -532,7 +532,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-1",
|
||||
},
|
||||
|
|
@ -552,7 +552,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "baz",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-1|location-2",
|
||||
"net_topology": "net_topology-1",
|
||||
|
|
@ -566,7 +566,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bax",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-2",
|
||||
"net_topology": "net_topology-1|net_topology-2",
|
||||
|
|
@ -581,7 +581,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bac",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "idc-1",
|
||||
"location": "location-2",
|
||||
"net_topology": "net_topology-1|net_topology-2",
|
||||
|
|
@ -621,7 +621,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
schedulerClusters: []model.SchedulerCluster{
|
||||
{
|
||||
Name: "foo",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "IDC-1",
|
||||
"location": "LOCATION-2",
|
||||
},
|
||||
|
|
@ -641,7 +641,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bar",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "IDC-1",
|
||||
"location": "LOCATION-1",
|
||||
},
|
||||
|
|
@ -661,7 +661,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "baz",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "IDC-1",
|
||||
"location": "LOCATION-1|LOCATION-2",
|
||||
"net_topology": "NET_TOPOLOGY-1",
|
||||
|
|
@ -675,7 +675,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bax",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "IDC-1",
|
||||
"location": "LOCATION-2",
|
||||
"net_topology": "NET_TOPOLOGY-1|NET_TOPOLOGY-2",
|
||||
|
|
@ -690,7 +690,7 @@ func TestSchedulerCluster(t *testing.T) {
|
|||
},
|
||||
{
|
||||
Name: "bac",
|
||||
Scopes: map[string]interface{}{
|
||||
Scopes: map[string]any{
|
||||
"idc": "IDC-1",
|
||||
"location": "LOCATION-2",
|
||||
"net_topology": "NET_TOPOLOGY-1|NET_TOPOLOGY-2",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ func (s *searcher) FindSchedulerClusters(ctx context.Context, schedulerClusters
|
|||
return []model.SchedulerCluster{{Name: "foo"}}, nil
|
||||
}
|
||||
|
||||
func DragonflyPluginInit(option map[string]string) (interface{}, map[string]string, error) {
|
||||
func DragonflyPluginInit(option map[string]string) (any, map[string]string, error) {
|
||||
return &searcher{}, map[string]string{"type": "manager", "name": "searcher"}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (s *service) CreatePreheatJob(ctx context.Context, json types.CreatePreheat
|
|||
func (s *service) pollingJob(ctx context.Context, id uint, taskID string) {
|
||||
var job model.Job
|
||||
|
||||
if _, _, err := retry.Run(ctx, func() (interface{}, bool, error) {
|
||||
if _, _, err := retry.Run(ctx, func() (any, bool, error) {
|
||||
groupJob, err := s.job.GetGroupJobState(taskID)
|
||||
if err != nil {
|
||||
logger.Errorf("polling job %d and task %s failed: %v", id, taskID, err)
|
||||
|
|
|
|||
|
|
@ -17,13 +17,13 @@
|
|||
package types
|
||||
|
||||
type CreateJobRequest struct {
|
||||
BIO string `json:"bio" binding:"omitempty"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Args map[string]interface{} `json:"args" binding:"omitempty"`
|
||||
Result map[string]interface{} `json:"result" binding:"omitempty"`
|
||||
UserID uint `json:"user_id" binding:"omitempty"`
|
||||
SeedPeerClusterIDs []uint `json:"seed_peer_cluster_ids" binding:"omitempty"`
|
||||
SchedulerClusterIDs []uint `json:"scheduler_cluster_ids" binding:"omitempty"`
|
||||
BIO string `json:"bio" binding:"omitempty"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Args map[string]any `json:"args" binding:"omitempty"`
|
||||
Result map[string]any `json:"result" binding:"omitempty"`
|
||||
UserID uint `json:"user_id" binding:"omitempty"`
|
||||
SeedPeerClusterIDs []uint `json:"seed_peer_cluster_ids" binding:"omitempty"`
|
||||
SchedulerClusterIDs []uint `json:"scheduler_cluster_ids" binding:"omitempty"`
|
||||
}
|
||||
|
||||
type UpdateJobRequest struct {
|
||||
|
|
@ -44,12 +44,12 @@ type GetJobsQuery struct {
|
|||
}
|
||||
|
||||
type CreatePreheatJobRequest struct {
|
||||
BIO string `json:"bio" binding:"omitempty"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Args PreheatArgs `json:"args" binding:"omitempty"`
|
||||
Result map[string]interface{} `json:"result" binding:"omitempty"`
|
||||
UserID uint `json:"user_id" binding:"omitempty"`
|
||||
SchedulerClusterIDs []uint `json:"scheduler_cluster_ids" binding:"omitempty"`
|
||||
BIO string `json:"bio" binding:"omitempty"`
|
||||
Type string `json:"type" binding:"required"`
|
||||
Args PreheatArgs `json:"args" binding:"omitempty"`
|
||||
Result map[string]any `json:"result" binding:"omitempty"`
|
||||
UserID uint `json:"user_id" binding:"omitempty"`
|
||||
SchedulerClusterIDs []uint `json:"scheduler_cluster_ids" binding:"omitempty"`
|
||||
}
|
||||
|
||||
type PreheatArgs struct {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import (
|
|||
)
|
||||
|
||||
type Item struct {
|
||||
Object interface{}
|
||||
Object any
|
||||
Expiration int64
|
||||
}
|
||||
|
||||
|
|
@ -54,15 +54,15 @@ const (
|
|||
)
|
||||
|
||||
type Cache interface {
|
||||
Set(k string, x interface{}, d time.Duration)
|
||||
SetDefault(k string, x interface{})
|
||||
Add(k string, x interface{}, d time.Duration) error
|
||||
Get(k string) (interface{}, bool)
|
||||
GetWithExpiration(k string) (interface{}, time.Time, bool)
|
||||
Set(k string, x any, d time.Duration)
|
||||
SetDefault(k string, x any)
|
||||
Add(k string, x any, d time.Duration) error
|
||||
Get(k string) (any, bool)
|
||||
GetWithExpiration(k string) (any, time.Time, bool)
|
||||
Delete(k string)
|
||||
DeleteExpired()
|
||||
Keys() []string
|
||||
OnEvicted(f func(string, interface{}))
|
||||
OnEvicted(f func(string, any))
|
||||
Save(w io.Writer) (err error)
|
||||
SaveFile(fname string) error
|
||||
Load(r io.Reader) error
|
||||
|
|
@ -76,14 +76,14 @@ type cache struct {
|
|||
defaultExpiration time.Duration
|
||||
items map[string]Item
|
||||
mu sync.RWMutex
|
||||
onEvicted func(string, interface{})
|
||||
onEvicted func(string, any)
|
||||
janitor *janitor
|
||||
}
|
||||
|
||||
// Add an item to the cache, replacing any existing item. If the duration is 0
|
||||
// (DefaultExpiration), the cache's default expiration time is used. If it is -1
|
||||
// (NoExpiration), the item never expires.
|
||||
func (c *cache) Set(k string, x interface{}, d time.Duration) {
|
||||
func (c *cache) Set(k string, x any, d time.Duration) {
|
||||
// "Inlining" of set
|
||||
var e int64
|
||||
if d == DefaultExpiration {
|
||||
|
|
@ -102,7 +102,7 @@ func (c *cache) Set(k string, x interface{}, d time.Duration) {
|
|||
c.mu.Unlock()
|
||||
}
|
||||
|
||||
func (c *cache) set(k string, x interface{}, d time.Duration) {
|
||||
func (c *cache) set(k string, x any, d time.Duration) {
|
||||
var e int64
|
||||
if d == DefaultExpiration {
|
||||
d = c.defaultExpiration
|
||||
|
|
@ -118,13 +118,13 @@ func (c *cache) set(k string, x interface{}, d time.Duration) {
|
|||
|
||||
// Add an item to the cache, replacing any existing item, using the default
|
||||
// expiration.
|
||||
func (c *cache) SetDefault(k string, x interface{}) {
|
||||
func (c *cache) SetDefault(k string, x any) {
|
||||
c.Set(k, x, DefaultExpiration)
|
||||
}
|
||||
|
||||
// Add an item to the cache only if an item doesn't already exist for the given
|
||||
// key, or if the existing item has expired. Returns an error otherwise.
|
||||
func (c *cache) Add(k string, x interface{}, d time.Duration) error {
|
||||
func (c *cache) Add(k string, x any, d time.Duration) error {
|
||||
c.mu.Lock()
|
||||
_, found := c.get(k)
|
||||
if found {
|
||||
|
|
@ -138,7 +138,7 @@ func (c *cache) Add(k string, x interface{}, d time.Duration) error {
|
|||
|
||||
// Get an item from the cache. Returns the item or nil, and a bool indicating
|
||||
// whether the key was found.
|
||||
func (c *cache) Get(k string) (interface{}, bool) {
|
||||
func (c *cache) Get(k string) (any, bool) {
|
||||
c.mu.RLock()
|
||||
// "Inlining" of get and Expired
|
||||
item, found := c.items[k]
|
||||
|
|
@ -155,7 +155,7 @@ func (c *cache) Get(k string) (interface{}, bool) {
|
|||
// It returns the item or nil, the expiration time if one is set (if the item
|
||||
// never expires a zero value for time.Time is returned), and a bool indicating
|
||||
// whether the key was found.
|
||||
func (c *cache) GetWithExpiration(k string) (interface{}, time.Time, bool) {
|
||||
func (c *cache) GetWithExpiration(k string) (any, time.Time, bool) {
|
||||
c.mu.RLock()
|
||||
// "Inlining" of get and Expired
|
||||
item, found := c.items[k]
|
||||
|
|
@ -181,7 +181,7 @@ func (c *cache) GetWithExpiration(k string) (interface{}, time.Time, bool) {
|
|||
return item.Object, time.Time{}, true
|
||||
}
|
||||
|
||||
func (c *cache) get(k string) (interface{}, bool) {
|
||||
func (c *cache) get(k string) (any, bool) {
|
||||
item, found := c.items[k]
|
||||
if !found {
|
||||
return nil, false
|
||||
|
|
@ -205,7 +205,7 @@ func (c *cache) Delete(k string) {
|
|||
}
|
||||
}
|
||||
|
||||
func (c *cache) delete(k string) (interface{}, bool) {
|
||||
func (c *cache) delete(k string) (any, bool) {
|
||||
if c.onEvicted != nil {
|
||||
if v, found := c.items[k]; found {
|
||||
delete(c.items, k)
|
||||
|
|
@ -218,7 +218,7 @@ func (c *cache) delete(k string) (interface{}, bool) {
|
|||
|
||||
type keyAndValue struct {
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
}
|
||||
|
||||
// Delete all expired items from the cache.
|
||||
|
|
@ -257,7 +257,7 @@ func (c *cache) Keys() []string {
|
|||
// Sets an (optional) function that is called with the key and value when an
|
||||
// item is evicted from the cache. (Including when it is deleted manually, but
|
||||
// not when it is overwritten.) Set to nil to disable.
|
||||
func (c *cache) OnEvicted(f func(string, interface{})) {
|
||||
func (c *cache) OnEvicted(f func(string, any)) {
|
||||
c.mu.Lock()
|
||||
c.onEvicted = f
|
||||
c.mu.Unlock()
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ func TestOnEvicted(t *testing.T) {
|
|||
tc := New(DefaultExpiration, 0)
|
||||
tc.Set(v1, 3, DefaultExpiration)
|
||||
works := false
|
||||
tc.OnEvicted(func(k string, v interface{}) {
|
||||
tc.OnEvicted(func(k string, v any) {
|
||||
if k == v1 && v.(int) == 3 {
|
||||
works = true
|
||||
}
|
||||
|
|
@ -423,7 +423,7 @@ func BenchmarkRWMutexMapGet(b *testing.B) {
|
|||
func BenchmarkRWMutexInterfaceMapGetStruct(b *testing.B) {
|
||||
b.StopTimer()
|
||||
s := struct{ name string }{name: v1}
|
||||
m := map[interface{}]string{
|
||||
m := map[any]string{
|
||||
s: v2,
|
||||
}
|
||||
var mu sync.RWMutex
|
||||
|
|
@ -437,7 +437,7 @@ func BenchmarkRWMutexInterfaceMapGetStruct(b *testing.B) {
|
|||
|
||||
func BenchmarkRWMutexInterfaceMapGetString(b *testing.B) {
|
||||
b.StopTimer()
|
||||
m := map[interface{}]string{
|
||||
m := map[any]string{
|
||||
v1: v2,
|
||||
}
|
||||
var mu sync.RWMutex
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (m *MockSafeSet) EXPECT() *MockSafeSetMockRecorder {
|
|||
}
|
||||
|
||||
// Add mocks base method.
|
||||
func (m *MockSafeSet) Add(arg0 interface{}) bool {
|
||||
func (m *MockSafeSet) Add(arg0 any) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Add", arg0)
|
||||
ret0, _ := ret[0].(bool)
|
||||
|
|
@ -60,7 +60,7 @@ func (mr *MockSafeSetMockRecorder) Clear() *gomock.Call {
|
|||
}
|
||||
|
||||
// Contains mocks base method.
|
||||
func (m *MockSafeSet) Contains(arg0 ...interface{}) bool {
|
||||
func (m *MockSafeSet) Contains(arg0 ...any) bool {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{}
|
||||
for _, a := range arg0 {
|
||||
|
|
@ -78,7 +78,7 @@ func (mr *MockSafeSetMockRecorder) Contains(arg0 ...interface{}) *gomock.Call {
|
|||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockSafeSet) Delete(arg0 interface{}) {
|
||||
func (m *MockSafeSet) Delete(arg0 any) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Delete", arg0)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func (mr *MockSafeSetMockRecorder) Len() *gomock.Call {
|
|||
}
|
||||
|
||||
// Range mocks base method.
|
||||
func (m *MockSafeSet) Range(arg0 func(interface{}) bool) {
|
||||
func (m *MockSafeSet) Range(arg0 func(any) bool) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Range", arg0)
|
||||
}
|
||||
|
|
@ -116,10 +116,10 @@ func (mr *MockSafeSetMockRecorder) Range(arg0 interface{}) *gomock.Call {
|
|||
}
|
||||
|
||||
// Values mocks base method.
|
||||
func (m *MockSafeSet) Values() []interface{} {
|
||||
func (m *MockSafeSet) Values() []any {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Values")
|
||||
ret0, _ := ret[0].([]interface{})
|
||||
ret0, _ := ret[0].([]any)
|
||||
return ret0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (m *MockSet) EXPECT() *MockSetMockRecorder {
|
|||
}
|
||||
|
||||
// Add mocks base method.
|
||||
func (m *MockSet) Add(arg0 interface{}) bool {
|
||||
func (m *MockSet) Add(arg0 any) bool {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Add", arg0)
|
||||
ret0, _ := ret[0].(bool)
|
||||
|
|
@ -60,7 +60,7 @@ func (mr *MockSetMockRecorder) Clear() *gomock.Call {
|
|||
}
|
||||
|
||||
// Contains mocks base method.
|
||||
func (m *MockSet) Contains(arg0 ...interface{}) bool {
|
||||
func (m *MockSet) Contains(arg0 ...any) bool {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{}
|
||||
for _, a := range arg0 {
|
||||
|
|
@ -78,7 +78,7 @@ func (mr *MockSetMockRecorder) Contains(arg0 ...interface{}) *gomock.Call {
|
|||
}
|
||||
|
||||
// Delete mocks base method.
|
||||
func (m *MockSet) Delete(arg0 interface{}) {
|
||||
func (m *MockSet) Delete(arg0 any) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Delete", arg0)
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ func (mr *MockSetMockRecorder) Len() *gomock.Call {
|
|||
}
|
||||
|
||||
// Range mocks base method.
|
||||
func (m *MockSet) Range(arg0 func(interface{}) bool) {
|
||||
func (m *MockSet) Range(arg0 func(any) bool) {
|
||||
m.ctrl.T.Helper()
|
||||
m.ctrl.Call(m, "Range", arg0)
|
||||
}
|
||||
|
|
@ -116,10 +116,10 @@ func (mr *MockSetMockRecorder) Range(arg0 interface{}) *gomock.Call {
|
|||
}
|
||||
|
||||
// Values mocks base method.
|
||||
func (m *MockSet) Values() []interface{} {
|
||||
func (m *MockSet) Values() []any {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "Values")
|
||||
ret0, _ := ret[0].([]interface{})
|
||||
ret0, _ := ret[0].([]any)
|
||||
return ret0
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,30 +23,30 @@ import (
|
|||
)
|
||||
|
||||
type SafeSet interface {
|
||||
Values() []interface{}
|
||||
Add(interface{}) bool
|
||||
Delete(interface{})
|
||||
Contains(...interface{}) bool
|
||||
Values() []any
|
||||
Add(any) bool
|
||||
Delete(any)
|
||||
Contains(...any) bool
|
||||
Len() uint
|
||||
Range(func(interface{}) bool)
|
||||
Range(func(any) bool)
|
||||
Clear()
|
||||
}
|
||||
|
||||
type safeSet struct {
|
||||
mu *sync.RWMutex
|
||||
data map[interface{}]struct{}
|
||||
data map[any]struct{}
|
||||
}
|
||||
|
||||
func NewSafeSet() SafeSet {
|
||||
return &safeSet{
|
||||
mu: &sync.RWMutex{},
|
||||
data: make(map[interface{}]struct{}),
|
||||
data: make(map[any]struct{}),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *safeSet) Values() []interface{} {
|
||||
var result []interface{}
|
||||
s.Range(func(v interface{}) bool {
|
||||
func (s *safeSet) Values() []any {
|
||||
var result []any
|
||||
s.Range(func(v any) bool {
|
||||
result = append(result, v)
|
||||
return true
|
||||
})
|
||||
|
|
@ -54,7 +54,7 @@ func (s *safeSet) Values() []interface{} {
|
|||
return result
|
||||
}
|
||||
|
||||
func (s *safeSet) Add(v interface{}) bool {
|
||||
func (s *safeSet) Add(v any) bool {
|
||||
s.mu.RLock()
|
||||
_, found := s.data[v]
|
||||
if found {
|
||||
|
|
@ -69,13 +69,13 @@ func (s *safeSet) Add(v interface{}) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (s *safeSet) Delete(v interface{}) {
|
||||
func (s *safeSet) Delete(v any) {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
delete(s.data, v)
|
||||
}
|
||||
|
||||
func (s *safeSet) Contains(vals ...interface{}) bool {
|
||||
func (s *safeSet) Contains(vals ...any) bool {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
for _, v := range vals {
|
||||
|
|
@ -93,7 +93,7 @@ func (s *safeSet) Len() uint {
|
|||
return uint(len(s.data))
|
||||
}
|
||||
|
||||
func (s *safeSet) Range(fn func(interface{}) bool) {
|
||||
func (s *safeSet) Range(fn func(any) bool) {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
for v := range s.data {
|
||||
|
|
@ -106,5 +106,5 @@ func (s *safeSet) Range(fn func(interface{}) bool) {
|
|||
func (s *safeSet) Clear() {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
s.data = make(map[interface{}]struct{})
|
||||
s.data = make(map[any]struct{})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,26 +30,26 @@ const N = 1000
|
|||
func TestSafeSetAdd(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, ok bool, s SafeSet, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, ok bool, s SafeSet, value any)
|
||||
}{
|
||||
{
|
||||
name: "add value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, ok bool, s SafeSet, value interface{}) {
|
||||
expect: func(t *testing.T, ok bool, s SafeSet, value any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(ok, true)
|
||||
assert.Equal(s.Values(), []interface{}{value})
|
||||
assert.Equal(s.Values(), []any{value})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add value failed",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, _ bool, s SafeSet, value interface{}) {
|
||||
expect: func(t *testing.T, _ bool, s SafeSet, value any) {
|
||||
assert := assert.New(t)
|
||||
ok := s.Add("foo")
|
||||
assert.Equal(ok, false)
|
||||
assert.Equal(s.Values(), []interface{}{value})
|
||||
assert.Equal(s.Values(), []any{value})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -88,13 +88,13 @@ func TestSafeSetAdd_Concurrent(t *testing.T) {
|
|||
func TestSafeSetDelete(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, s SafeSet, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, s SafeSet, value any)
|
||||
}{
|
||||
{
|
||||
name: "delete value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s SafeSet, value interface{}) {
|
||||
expect: func(t *testing.T, s SafeSet, value any) {
|
||||
assert := assert.New(t)
|
||||
s.Delete(value)
|
||||
assert.Equal(s.Len(), uint(0))
|
||||
|
|
@ -103,7 +103,7 @@ func TestSafeSetDelete(t *testing.T) {
|
|||
{
|
||||
name: "delete value does not exist",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s SafeSet, _ interface{}) {
|
||||
expect: func(t *testing.T, s SafeSet, _ any) {
|
||||
assert := assert.New(t)
|
||||
s.Delete("bar")
|
||||
assert.Equal(s.Len(), uint(1))
|
||||
|
|
@ -147,13 +147,13 @@ func TestSafeSetDelete_Concurrent(t *testing.T) {
|
|||
func TestSafeSetContains(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, s SafeSet, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, s SafeSet, value any)
|
||||
}{
|
||||
{
|
||||
name: "contains value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s SafeSet, value interface{}) {
|
||||
expect: func(t *testing.T, s SafeSet, value any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Contains(value), true)
|
||||
},
|
||||
|
|
@ -161,7 +161,7 @@ func TestSafeSetContains(t *testing.T) {
|
|||
{
|
||||
name: "contains value does not exist",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s SafeSet, _ interface{}) {
|
||||
expect: func(t *testing.T, s SafeSet, _ any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Contains("bar"), false)
|
||||
},
|
||||
|
|
@ -182,7 +182,7 @@ func TestSafeSetContains_Concurrent(t *testing.T) {
|
|||
|
||||
s := NewSafeSet()
|
||||
nums := rand.Perm(N)
|
||||
interfaces := make([]interface{}, 0)
|
||||
interfaces := make([]any, 0)
|
||||
for _, v := range nums {
|
||||
s.Add(v)
|
||||
interfaces = append(interfaces, v)
|
||||
|
|
@ -263,14 +263,14 @@ func TestSafeSetValues(t *testing.T) {
|
|||
expect: func(t *testing.T, s SafeSet) {
|
||||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
assert.Equal(s.Values(), []interface{}{"foo"})
|
||||
assert.Equal(s.Values(), []any{"foo"})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "get empty values",
|
||||
expect: func(t *testing.T, s SafeSet) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -327,7 +327,7 @@ func TestSafeSetRange(t *testing.T) {
|
|||
expect: func(t *testing.T, s SafeSet) {
|
||||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
s.Range(func(v interface{}) bool {
|
||||
s.Range(func(v any) bool {
|
||||
assert.Equal(v, "foo")
|
||||
return true
|
||||
})
|
||||
|
|
@ -339,7 +339,7 @@ func TestSafeSetRange(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
s.Add("bar")
|
||||
s.Range(func(v interface{}) bool {
|
||||
s.Range(func(v any) bool {
|
||||
assert.Equal(s.Contains(v), true)
|
||||
return false
|
||||
})
|
||||
|
|
@ -365,7 +365,7 @@ func TestSafeSetRange_Concurrent(t *testing.T) {
|
|||
go func() {
|
||||
elems := s.Values()
|
||||
i := 0
|
||||
s.Range(func(v interface{}) bool {
|
||||
s.Range(func(v any) bool {
|
||||
i++
|
||||
return true
|
||||
})
|
||||
|
|
@ -391,7 +391,7 @@ func TestSafeSetClear(t *testing.T) {
|
|||
expect: func(t *testing.T, s SafeSet) {
|
||||
assert := assert.New(t)
|
||||
s.Clear()
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -400,9 +400,9 @@ func TestSafeSetClear(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
assert.Equal(s.Add("foo"), true)
|
||||
s.Clear()
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
assert.Equal(s.Add("foo"), true)
|
||||
assert.Equal(s.Values(), []interface{}{"foo"})
|
||||
assert.Equal(s.Values(), []any{"foo"})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,24 +19,24 @@
|
|||
package set
|
||||
|
||||
type Set interface {
|
||||
Values() []interface{}
|
||||
Add(interface{}) bool
|
||||
Delete(interface{})
|
||||
Contains(...interface{}) bool
|
||||
Values() []any
|
||||
Add(any) bool
|
||||
Delete(any)
|
||||
Contains(...any) bool
|
||||
Len() uint
|
||||
Range(func(interface{}) bool)
|
||||
Range(func(any) bool)
|
||||
Clear()
|
||||
}
|
||||
|
||||
type set map[interface{}]struct{}
|
||||
type set map[any]struct{}
|
||||
|
||||
func New() Set {
|
||||
return &set{}
|
||||
}
|
||||
|
||||
func (s *set) Values() []interface{} {
|
||||
var result []interface{}
|
||||
s.Range(func(v interface{}) bool {
|
||||
func (s *set) Values() []any {
|
||||
var result []any
|
||||
s.Range(func(v any) bool {
|
||||
result = append(result, v)
|
||||
return true
|
||||
})
|
||||
|
|
@ -44,7 +44,7 @@ func (s *set) Values() []interface{} {
|
|||
return result
|
||||
}
|
||||
|
||||
func (s *set) Add(v interface{}) bool {
|
||||
func (s *set) Add(v any) bool {
|
||||
_, found := (*s)[v]
|
||||
if found {
|
||||
return false
|
||||
|
|
@ -54,11 +54,11 @@ func (s *set) Add(v interface{}) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (s *set) Delete(v interface{}) {
|
||||
func (s *set) Delete(v any) {
|
||||
delete(*s, v)
|
||||
}
|
||||
|
||||
func (s *set) Contains(vals ...interface{}) bool {
|
||||
func (s *set) Contains(vals ...any) bool {
|
||||
for _, v := range vals {
|
||||
if _, ok := (*s)[v]; !ok {
|
||||
return false
|
||||
|
|
@ -72,7 +72,7 @@ func (s *set) Len() uint {
|
|||
return uint(len(*s))
|
||||
}
|
||||
|
||||
func (s *set) Range(fn func(interface{}) bool) {
|
||||
func (s *set) Range(fn func(any) bool) {
|
||||
for v := range *s {
|
||||
if !fn(v) {
|
||||
break
|
||||
|
|
|
|||
|
|
@ -25,26 +25,26 @@ import (
|
|||
func TestSetAdd(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, ok bool, s Set, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, ok bool, s Set, value any)
|
||||
}{
|
||||
{
|
||||
name: "add value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, ok bool, s Set, value interface{}) {
|
||||
expect: func(t *testing.T, ok bool, s Set, value any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(ok, true)
|
||||
assert.Equal(s.Values(), []interface{}{value})
|
||||
assert.Equal(s.Values(), []any{value})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "add value failed",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, _ bool, s Set, value interface{}) {
|
||||
expect: func(t *testing.T, _ bool, s Set, value any) {
|
||||
assert := assert.New(t)
|
||||
ok := s.Add("foo")
|
||||
assert.Equal(ok, false)
|
||||
assert.Equal(s.Values(), []interface{}{value})
|
||||
assert.Equal(s.Values(), []any{value})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -60,13 +60,13 @@ func TestSetAdd(t *testing.T) {
|
|||
func TestSetDelete(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, s Set, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, s Set, value any)
|
||||
}{
|
||||
{
|
||||
name: "delete value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s Set, value interface{}) {
|
||||
expect: func(t *testing.T, s Set, value any) {
|
||||
assert := assert.New(t)
|
||||
s.Delete(value)
|
||||
assert.Equal(s.Len(), uint(0))
|
||||
|
|
@ -75,7 +75,7 @@ func TestSetDelete(t *testing.T) {
|
|||
{
|
||||
name: "delete value does not exist",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s Set, _ interface{}) {
|
||||
expect: func(t *testing.T, s Set, _ any) {
|
||||
assert := assert.New(t)
|
||||
s.Delete("bar")
|
||||
assert.Equal(s.Len(), uint(1))
|
||||
|
|
@ -95,13 +95,13 @@ func TestSetDelete(t *testing.T) {
|
|||
func TestSetContains(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
value interface{}
|
||||
expect func(t *testing.T, s Set, value interface{})
|
||||
value any
|
||||
expect func(t *testing.T, s Set, value any)
|
||||
}{
|
||||
{
|
||||
name: "contains value",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s Set, value interface{}) {
|
||||
expect: func(t *testing.T, s Set, value any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Contains(value), true)
|
||||
},
|
||||
|
|
@ -109,7 +109,7 @@ func TestSetContains(t *testing.T) {
|
|||
{
|
||||
name: "contains value does not exist",
|
||||
value: "foo",
|
||||
expect: func(t *testing.T, s Set, _ interface{}) {
|
||||
expect: func(t *testing.T, s Set, _ any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Contains("bar"), false)
|
||||
},
|
||||
|
|
@ -165,14 +165,14 @@ func TestSetValues(t *testing.T) {
|
|||
expect: func(t *testing.T, s Set) {
|
||||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
assert.Equal(s.Values(), []interface{}{"foo"})
|
||||
assert.Equal(s.Values(), []any{"foo"})
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "get empty values",
|
||||
expect: func(t *testing.T, s Set) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -205,7 +205,7 @@ func TestSetRange(t *testing.T) {
|
|||
expect: func(t *testing.T, s Set) {
|
||||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
s.Range(func(v interface{}) bool {
|
||||
s.Range(func(v any) bool {
|
||||
assert.Equal(v, "foo")
|
||||
return true
|
||||
})
|
||||
|
|
@ -217,7 +217,7 @@ func TestSetRange(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
s.Add("foo")
|
||||
s.Add("bar")
|
||||
s.Range(func(v interface{}) bool {
|
||||
s.Range(func(v any) bool {
|
||||
assert.Equal(s.Contains(v), true)
|
||||
return false
|
||||
})
|
||||
|
|
@ -243,7 +243,7 @@ func TestSetClear(t *testing.T) {
|
|||
expect: func(t *testing.T, s Set) {
|
||||
assert := assert.New(t)
|
||||
s.Clear()
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -252,9 +252,9 @@ func TestSetClear(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
assert.Equal(s.Add("foo"), true)
|
||||
s.Clear()
|
||||
assert.Equal(s.Values(), []interface{}(nil))
|
||||
assert.Equal(s.Values(), []any(nil))
|
||||
assert.Equal(s.Add("foo"), true)
|
||||
assert.Equal(s.Values(), []interface{}{"foo"})
|
||||
assert.Equal(s.Values(), []any{"foo"})
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ func (n NetAddr) String() string {
|
|||
}
|
||||
|
||||
func (n *NetAddr) UnmarshalJSON(b []byte) error {
|
||||
var v interface{}
|
||||
var v any
|
||||
if err := json.Unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -67,7 +67,7 @@ func (n *NetAddr) UnmarshalJSON(b []byte) error {
|
|||
n.Type = TCP
|
||||
n.Addr = value
|
||||
return nil
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
if err := n.unmarshal(json.Unmarshal, b); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -88,11 +88,11 @@ func (n *NetAddr) UnmarshalYAML(node *yaml.Node) error {
|
|||
n.Addr = addr
|
||||
return nil
|
||||
case yaml.MappingNode:
|
||||
var m = make(map[string]interface{})
|
||||
var m = make(map[string]any)
|
||||
for i := 0; i < len(node.Content); i += 2 {
|
||||
var (
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
)
|
||||
if err := node.Content[i].Decode(&key); err != nil {
|
||||
return err
|
||||
|
|
@ -117,7 +117,7 @@ func (n *NetAddr) UnmarshalYAML(node *yaml.Node) error {
|
|||
}
|
||||
}
|
||||
|
||||
func (n *NetAddr) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
|
||||
func (n *NetAddr) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
|
||||
nt := struct {
|
||||
Type NetworkType `json:"type" yaml:"type"`
|
||||
Addr string `json:"addr" yaml:"addr"` // see https://github.com/grpc/grpc/blob/master/doc/naming.md
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (g gc) RunAll() {
|
|||
}
|
||||
|
||||
func (g gc) Serve() {
|
||||
g.tasks.Range(func(k interface{}, v interface{}) bool {
|
||||
g.tasks.Range(func(k, v any) bool {
|
||||
go func() {
|
||||
task := v.(Task)
|
||||
tick := time.NewTicker(task.Interval)
|
||||
|
|
@ -123,7 +123,7 @@ func (g gc) Stop() {
|
|||
}
|
||||
|
||||
func (g gc) runAll() {
|
||||
g.tasks.Range(func(k, v interface{}) bool {
|
||||
g.tasks.Range(func(k, v any) bool {
|
||||
go g.run(v.(Task))
|
||||
return true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ func TestGCRun(t *testing.T) {
|
|||
defer wg.Wait()
|
||||
|
||||
gomock.InOrder(
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
mr.EXPECT().RunGC().Do(func() { wg.Done() }).Return(nil).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
)
|
||||
|
||||
if err := gc.Run(id); err != nil {
|
||||
|
|
@ -143,10 +143,10 @@ func TestGCRun(t *testing.T) {
|
|||
|
||||
err := errors.New("bar")
|
||||
gomock.InOrder(
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
mr.EXPECT().RunGC().Do(func() { wg.Done() }).Return(err).Times(1),
|
||||
ml.EXPECT().Errorf(gomock.Any(), gomock.Eq("foo"), gomock.Eq(err)).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Errorf(gomock.Any(), gomock.Eq("foo"), gomock.Eq(err)).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
)
|
||||
|
||||
if err := gc.Run(id); err != nil {
|
||||
|
|
@ -214,9 +214,9 @@ func TestGCRunAll(t *testing.T) {
|
|||
defer wg.Wait()
|
||||
|
||||
gomock.InOrder(
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
mr.EXPECT().RunGC().Do(func() { wg.Done() }).Return(nil).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
)
|
||||
|
||||
gc.RunAll()
|
||||
|
|
@ -241,10 +241,10 @@ func TestGCRunAll(t *testing.T) {
|
|||
|
||||
err := errors.New("baz")
|
||||
gomock.InOrder(
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
mr.EXPECT().RunGC().Do(func() { wg.Done() }).Return(err).Times(1),
|
||||
ml.EXPECT().Errorf(gomock.Any(), gomock.Eq("foo"), gomock.Eq(err)).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template interface{}, args ...interface{}) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Errorf(gomock.Any(), gomock.Eq("foo"), gomock.Eq(err)).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
ml.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template any, args ...any) { wg.Done() }).Times(1),
|
||||
)
|
||||
|
||||
gc.RunAll()
|
||||
|
|
@ -293,7 +293,7 @@ func TestGCServe(t *testing.T) {
|
|||
t.Fatal(err)
|
||||
}
|
||||
|
||||
mockLogger.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template string, args ...interface{}) {
|
||||
mockLogger.EXPECT().Infof(gomock.Any(), gomock.Eq("foo")).Do(func(template string, args ...any) {
|
||||
wg.Done()
|
||||
}).Times(1)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ package gc
|
|||
// Logger is the interface used in GC for logging.
|
||||
type Logger interface {
|
||||
// Infof logs routine messages for GC.
|
||||
Infof(template string, args ...interface{})
|
||||
Infof(template string, args ...any)
|
||||
// Error logs error messages for GC.
|
||||
Errorf(template string, args ...interface{})
|
||||
Errorf(template string, args ...any)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (m *MockLogger) EXPECT() *MockLoggerMockRecorder {
|
|||
}
|
||||
|
||||
// Errorf mocks base method.
|
||||
func (m *MockLogger) Errorf(template string, args ...interface{}) {
|
||||
func (m *MockLogger) Errorf(template string, args ...any) {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{template}
|
||||
for _, a := range args {
|
||||
|
|
@ -51,7 +51,7 @@ func (mr *MockLoggerMockRecorder) Errorf(template interface{}, args ...interface
|
|||
}
|
||||
|
||||
// Infof mocks base method.
|
||||
func (m *MockLogger) Infof(template string, args ...interface{}) {
|
||||
func (m *MockLogger) Infof(template string, args ...any) {
|
||||
m.ctrl.T.Helper()
|
||||
varargs := []interface{}{template}
|
||||
for _, a := range args {
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ func TestPeerID(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
ip string
|
||||
expect func(t *testing.T, d interface{})
|
||||
expect func(t *testing.T, d any)
|
||||
}{
|
||||
{
|
||||
name: "generate PeerID with ipv4",
|
||||
ip: "127.0.0.1",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("127.0.0.1-.*-.*", d)
|
||||
},
|
||||
|
|
@ -39,7 +39,7 @@ func TestPeerID(t *testing.T) {
|
|||
{
|
||||
name: "generate PeerID with ipv6",
|
||||
ip: "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b-.*-.*", d)
|
||||
},
|
||||
|
|
@ -47,7 +47,7 @@ func TestPeerID(t *testing.T) {
|
|||
{
|
||||
name: "generate PeerID with empty string",
|
||||
ip: "",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("-.*-.*", d)
|
||||
},
|
||||
|
|
@ -66,12 +66,12 @@ func TestSeedPeerID(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
ip string
|
||||
expect func(t *testing.T, d interface{})
|
||||
expect func(t *testing.T, d any)
|
||||
}{
|
||||
{
|
||||
name: "generate SeedPeerID with ipv4",
|
||||
ip: "127.0.0.1",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("127.0.0.1-.*-.*_Seed", d)
|
||||
},
|
||||
|
|
@ -79,7 +79,7 @@ func TestSeedPeerID(t *testing.T) {
|
|||
{
|
||||
name: "generate SeedPeerID with ipv6",
|
||||
ip: "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b-.*-.*_Seed", d)
|
||||
},
|
||||
|
|
@ -87,7 +87,7 @@ func TestSeedPeerID(t *testing.T) {
|
|||
{
|
||||
name: "generate SeedPeerID with empty string",
|
||||
ip: "",
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Regexp("-.*-.*_Seed", d)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -30,13 +30,13 @@ func TestTaskID(t *testing.T) {
|
|||
url string
|
||||
meta *base.UrlMeta
|
||||
ignoreRange bool
|
||||
expect func(t *testing.T, d interface{})
|
||||
expect func(t *testing.T, d any)
|
||||
}{
|
||||
{
|
||||
name: "generate taskID with url",
|
||||
url: "https://example.com",
|
||||
meta: nil,
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("100680ad546ce6a577f42f52df33b4cfdca756859e664b8d7de329b150d09ce9", d)
|
||||
},
|
||||
|
|
@ -49,7 +49,7 @@ func TestTaskID(t *testing.T) {
|
|||
Digest: "bar",
|
||||
Tag: "",
|
||||
},
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("aeee0e0a2a0c75130582641353c539aaf9011a0088b31347f7588e70e449a3e0", d)
|
||||
},
|
||||
|
|
@ -63,7 +63,7 @@ func TestTaskID(t *testing.T) {
|
|||
Tag: "",
|
||||
},
|
||||
ignoreRange: true,
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("63dee2822037636b0109876b58e95692233840753a882afa69b9b5ee82a6c57d", d)
|
||||
},
|
||||
|
|
@ -75,7 +75,7 @@ func TestTaskID(t *testing.T) {
|
|||
Tag: "foo",
|
||||
Filter: "foo&bar",
|
||||
},
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("2773851c628744fb7933003195db436ce397c1722920696c4274ff804d86920b", d)
|
||||
},
|
||||
|
|
@ -86,7 +86,7 @@ func TestTaskID(t *testing.T) {
|
|||
meta: &base.UrlMeta{
|
||||
Tag: "foo",
|
||||
},
|
||||
expect: func(t *testing.T, d interface{}) {
|
||||
expect: func(t *testing.T, d any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal("2773851c628744fb7933003195db436ce397c1722920696c4274ff804d86920b", d)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ func TestHeaderToMap(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
header http.Header
|
||||
expect func(t *testing.T, data interface{})
|
||||
expect func(t *testing.T, data any)
|
||||
}{
|
||||
{
|
||||
name: "normal conversion",
|
||||
|
|
@ -35,7 +35,7 @@ func TestHeaderToMap(t *testing.T) {
|
|||
"foo": {"foo"},
|
||||
"bar": {"bar"},
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := testifyassert.New(t)
|
||||
assert.EqualValues(data, map[string]string{
|
||||
"foo": "foo",
|
||||
|
|
@ -46,7 +46,7 @@ func TestHeaderToMap(t *testing.T) {
|
|||
{
|
||||
name: "header is empty",
|
||||
header: http.Header{},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := testifyassert.New(t)
|
||||
assert.EqualValues(data, map[string]string{})
|
||||
},
|
||||
|
|
@ -57,7 +57,7 @@ func TestHeaderToMap(t *testing.T) {
|
|||
"foo": {"foo1", "foo2"},
|
||||
"bar": {"bar"},
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := testifyassert.New(t)
|
||||
assert.EqualValues(data, map[string]string{
|
||||
"foo": "foo1",
|
||||
|
|
@ -79,7 +79,7 @@ func TestMapToHeader(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
m map[string]string
|
||||
expect func(t *testing.T, data interface{})
|
||||
expect func(t *testing.T, data any)
|
||||
}{
|
||||
{
|
||||
name: "normal conversion",
|
||||
|
|
@ -87,7 +87,7 @@ func TestMapToHeader(t *testing.T) {
|
|||
"Foo": "foo",
|
||||
"Bar": "bar",
|
||||
},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := testifyassert.New(t)
|
||||
assert.EqualValues(data, http.Header{
|
||||
"Foo": {"foo"},
|
||||
|
|
@ -98,7 +98,7 @@ func TestMapToHeader(t *testing.T) {
|
|||
{
|
||||
name: "map is empty",
|
||||
m: map[string]string{},
|
||||
expect: func(t *testing.T, data interface{}) {
|
||||
expect: func(t *testing.T, data any) {
|
||||
assert := testifyassert.New(t)
|
||||
assert.EqualValues(data, http.Header{})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,13 +24,13 @@ import (
|
|||
)
|
||||
|
||||
func Run(ctx context.Context,
|
||||
f func() (data interface{}, cancel bool, err error),
|
||||
f func() (data any, cancel bool, err error),
|
||||
initBackoff float64,
|
||||
maxBackoff float64,
|
||||
maxAttempts int,
|
||||
cause error) (interface{}, bool, error) {
|
||||
cause error) (any, bool, error) {
|
||||
var (
|
||||
res interface{}
|
||||
res any
|
||||
cancel bool
|
||||
)
|
||||
for i := 0; i < maxAttempts; i++ {
|
||||
|
|
|
|||
|
|
@ -1086,7 +1086,7 @@ func file_pkg_rpc_base_base_proto_rawDescGZIP() []byte {
|
|||
|
||||
var file_pkg_rpc_base_base_proto_enumTypes = make([]protoimpl.EnumInfo, 5)
|
||||
var file_pkg_rpc_base_base_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_pkg_rpc_base_base_proto_goTypes = []interface{}{
|
||||
var file_pkg_rpc_base_base_proto_goTypes = []any{
|
||||
(Code)(0), // 0: base.Code
|
||||
(PieceStyle)(0), // 1: base.PieceStyle
|
||||
(SizeScope)(0), // 2: base.SizeScope
|
||||
|
|
@ -1122,7 +1122,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GrpcDfError); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1134,7 +1134,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UrlMeta); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1146,7 +1146,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*HostLoad); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1158,7 +1158,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PieceTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1170,7 +1170,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PieceInfo); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1182,7 +1182,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ExtendAttribute); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1194,7 +1194,7 @@ func file_pkg_rpc_base_base_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_base_base_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_base_base_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PiecePacket); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
|
|||
|
|
@ -591,7 +591,7 @@ func (m *PiecePacket) Validate() error {
|
|||
for idx, item := range m.GetPieceInfos() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PiecePacketValidationError{
|
||||
field: fmt.Sprintf("PieceInfos[%v]", idx),
|
||||
|
|
@ -609,7 +609,7 @@ func (m *PiecePacket) Validate() error {
|
|||
|
||||
// no validation rules for PieceMd5Sign
|
||||
|
||||
if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PiecePacketValidationError{
|
||||
field: "ExtendAttribute",
|
||||
|
|
|
|||
|
|
@ -37,14 +37,14 @@ func NewGrpcDfError(code base.Code, msg string) *base.GrpcDfError {
|
|||
|
||||
// NewResWithCodeAndMsg returns a response ptr with code and msg,
|
||||
// ptr is a expected type ptr.
|
||||
func NewResWithCodeAndMsg(ptr interface{}, code base.Code, msg string) interface{} {
|
||||
func NewResWithCodeAndMsg(ptr any, code base.Code, msg string) any {
|
||||
typ := reflect.TypeOf(ptr)
|
||||
v := reflect.New(typ.Elem())
|
||||
|
||||
return v.Interface()
|
||||
}
|
||||
|
||||
func NewResWithErr(ptr interface{}, err error) interface{} {
|
||||
func NewResWithErr(ptr any, err error) any {
|
||||
st := status.Convert(err)
|
||||
var code base.Code
|
||||
switch st.Code() {
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ func file_pkg_rpc_cdnsystem_cdnsystem_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_pkg_rpc_cdnsystem_cdnsystem_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_pkg_rpc_cdnsystem_cdnsystem_proto_goTypes = []interface{}{
|
||||
var file_pkg_rpc_cdnsystem_cdnsystem_proto_goTypes = []any{
|
||||
(*SeedRequest)(nil), // 0: cdnsystem.SeedRequest
|
||||
(*PieceSeed)(nil), // 1: cdnsystem.PieceSeed
|
||||
(*base.UrlMeta)(nil), // 2: base.UrlMeta
|
||||
|
|
@ -327,7 +327,7 @@ func file_pkg_rpc_cdnsystem_cdnsystem_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_rpc_cdnsystem_cdnsystem_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_cdnsystem_cdnsystem_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SeedRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -339,7 +339,7 @@ func file_pkg_rpc_cdnsystem_cdnsystem_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_cdnsystem_cdnsystem_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_cdnsystem_cdnsystem_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PieceSeed); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -500,7 +500,7 @@ func RegisterSeederServer(s *grpc.Server, srv SeederServer) {
|
|||
s.RegisterService(&_Seeder_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Seeder_ObtainSeeds_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Seeder_ObtainSeeds_Handler(srv any, stream grpc.ServerStream) error {
|
||||
m := new(SeedRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
|
@ -521,7 +521,7 @@ func (x *seederObtainSeedsServer) Send(m *PieceSeed) error {
|
|||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _Seeder_GetPieceTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Seeder_GetPieceTasks_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(base.PieceTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -533,13 +533,13 @@ func _Seeder_GetPieceTasks_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
Server: srv,
|
||||
FullMethod: "/cdnsystem.Seeder/GetPieceTasks",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SeederServer).GetPieceTasks(ctx, req.(*base.PieceTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Seeder_SyncPieceTasks_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Seeder_SyncPieceTasks_Handler(srv any, stream grpc.ServerStream) error {
|
||||
return srv.(SeederServer).SyncPieceTasks(&seederSyncPieceTasksServer{stream})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (m *SeedRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SeedRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -149,7 +149,7 @@ func (m *PieceSeed) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PieceSeedValidationError{
|
||||
field: "PieceInfo",
|
||||
|
|
@ -169,7 +169,7 @@ func (m *PieceSeed) Validate() error {
|
|||
|
||||
// no validation rules for EndTime
|
||||
|
||||
if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PieceSeedValidationError{
|
||||
field: "ExtendAttribute",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func newPieceSeedStream(ctx context.Context, sc *cdnClient, hashKey string, sr *
|
|||
|
||||
func (pss *PieceSeedStream) initStream() error {
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client cdnsystem.SeederClient
|
||||
var err error
|
||||
client, target, err = pss.sc.getCdnClient(pss.hashKey, false)
|
||||
|
|
@ -110,7 +110,7 @@ func (pss *PieceSeedStream) replaceStream(cause error) error {
|
|||
return cause
|
||||
}
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client cdnsystem.SeederClient
|
||||
var err error
|
||||
client, target, err = pss.sc.getCdnClient(pss.hashKey, true)
|
||||
|
|
@ -136,7 +136,7 @@ func (pss *PieceSeedStream) replaceClient(key string, cause error) error {
|
|||
}
|
||||
pss.failedServers = append(pss.failedServers, preNode)
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client cdnsystem.SeederClient
|
||||
var err error
|
||||
client, target, err = pss.sc.getCdnClient(key, true)
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ func (conn *Connection) findCandidateClientConn(key string, exclusiveNodes sets.
|
|||
|
||||
type candidateClient struct {
|
||||
node string
|
||||
Ref interface{}
|
||||
Ref any
|
||||
}
|
||||
|
||||
func (conn *Connection) createClient(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
|
||||
|
|
@ -413,7 +413,7 @@ func (conn *Connection) Close() error {
|
|||
}
|
||||
}
|
||||
// gc hash keys
|
||||
conn.key2NodeMap.Range(func(key, value interface{}) bool {
|
||||
conn.key2NodeMap.Range(func(key, value any) bool {
|
||||
if value == serverNode {
|
||||
conn.key2NodeMap.Delete(key)
|
||||
logger.GrpcLogger.With("conn", conn.name).Infof("success gc key: %s associated with server node %s", key, serverNode)
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func (conn *Connection) startGC() {
|
|||
// TODO use anther locker, @santong
|
||||
conn.rwMutex.Lock()
|
||||
// range all connections and determine whether they are expired
|
||||
conn.accessNodeMap.Range(func(node, accessTime interface{}) bool {
|
||||
conn.accessNodeMap.Range(func(node, accessTime any) bool {
|
||||
serverNode := node.(string)
|
||||
totalNodeSize++
|
||||
atime := accessTime.(time.Time)
|
||||
|
|
@ -79,7 +79,7 @@ func (conn *Connection) startGC() {
|
|||
logger.GrpcLogger.With("conn", conn.name).Warnf("gc %d conns, cost: %.3f seconds", removedConnCount, timeElapse.Seconds())
|
||||
}
|
||||
actualTotal := 0
|
||||
conn.node2ClientMap.Range(func(key, value interface{}) bool {
|
||||
conn.node2ClientMap.Range(func(key, value any) bool {
|
||||
if value != nil {
|
||||
actualTotal++
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ func (conn *Connection) gcConn(node string) {
|
|||
conn.node2ClientMap.Delete(node)
|
||||
logger.GrpcLogger.With("conn", conn.name).Infof("success gc clientConn: %s", node)
|
||||
// gc hash keys
|
||||
conn.key2NodeMap.Range(func(key, value interface{}) bool {
|
||||
conn.key2NodeMap.Range(func(key, value any) bool {
|
||||
if value == node {
|
||||
conn.key2NodeMap.Delete(key)
|
||||
logger.GrpcLogger.With("conn", conn.name).Infof("success gc key: %s associated with server node %s", key, node)
|
||||
|
|
@ -115,7 +115,7 @@ var (
|
|||
messageReceived = messageType(attribute.Key("message.type").String("response"))
|
||||
)
|
||||
|
||||
func (m messageType) Event(ctx context.Context, id int, message interface{}) {
|
||||
func (m messageType) Event(ctx context.Context, id int, message any) {
|
||||
span := trace.SpanFromContext(ctx)
|
||||
if p, ok := message.(proto.Message); ok {
|
||||
content, _ := proto.Marshal(p)
|
||||
|
|
@ -136,7 +136,7 @@ type wrappedClientStream struct {
|
|||
sentMessageID int
|
||||
}
|
||||
|
||||
func (w *wrappedClientStream) RecvMsg(m interface{}) error {
|
||||
func (w *wrappedClientStream) RecvMsg(m any) error {
|
||||
err := w.ClientStream.RecvMsg(m)
|
||||
if err != nil && err != io.EOF {
|
||||
err = convertClientError(err)
|
||||
|
|
@ -149,7 +149,7 @@ func (w *wrappedClientStream) RecvMsg(m interface{}) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func (w *wrappedClientStream) SendMsg(m interface{}) error {
|
||||
func (w *wrappedClientStream) SendMsg(m any) error {
|
||||
err := w.ClientStream.SendMsg(m)
|
||||
w.sentMessageID++
|
||||
messageSent.Event(w.Context(), w.sentMessageID, m)
|
||||
|
|
@ -175,7 +175,7 @@ func streamClientInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grp
|
|||
}, nil
|
||||
}
|
||||
|
||||
func unaryClientInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
func unaryClientInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
||||
messageSent.Event(ctx, 1, req)
|
||||
err := invoker(ctx, method, req, reply, cc, opts...)
|
||||
|
||||
|
|
@ -213,8 +213,8 @@ type RetryMeta struct {
|
|||
MaxBackOff float64 // second
|
||||
}
|
||||
|
||||
func ExecuteWithRetry(f func() (interface{}, error), initBackoff float64, maxBackoff float64, maxAttempts int, cause error) (interface{}, error) {
|
||||
var res interface{}
|
||||
func ExecuteWithRetry(f func() (any, error), initBackoff float64, maxBackoff float64, maxAttempts int, cause error) (any, error) {
|
||||
var res any
|
||||
for i := 0; i < maxAttempts; i++ {
|
||||
if _, ok := cause.(*dferrors.DfError); ok {
|
||||
return res, cause
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ func (dc *daemonClient) SyncPieceTasks(ctx context.Context, target dfnet.NetAddr
|
|||
}
|
||||
|
||||
func (dc *daemonClient) CheckHealth(ctx context.Context, target dfnet.NetAddr, opts ...grpc.CallOption) (err error) {
|
||||
_, err = rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
_, err = rpc.ExecuteWithRetry(func() (any, error) {
|
||||
client, err := dc.getDaemonClientWithTarget(target.GetEndpoint())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect server %s: %v", target.GetEndpoint(), err)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ func newDownResultStream(ctx context.Context, dc *daemonClient, hashKey string,
|
|||
|
||||
func (drs *DownResultStream) initStream() error {
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client dfdaemon.DaemonClient
|
||||
var err error
|
||||
client, target, err = drs.dc.getDaemonClient(drs.hashKey, false)
|
||||
|
|
@ -119,7 +119,7 @@ func (drs *DownResultStream) replaceStream(cause error) error {
|
|||
return cause
|
||||
}
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client dfdaemon.DaemonClient
|
||||
var err error
|
||||
client, target, err = drs.dc.getDaemonClient(drs.hashKey, true)
|
||||
|
|
@ -146,7 +146,7 @@ func (drs *DownResultStream) replaceClient(cause error) error {
|
|||
drs.failedServers = append(drs.failedServers, preNode)
|
||||
|
||||
var target string
|
||||
stream, err := rpc.ExecuteWithRetry(func() (interface{}, error) {
|
||||
stream, err := rpc.ExecuteWithRetry(func() (any, error) {
|
||||
var client dfdaemon.DaemonClient
|
||||
var err error
|
||||
client, target, err = drs.dc.getDaemonClient(drs.hashKey, true)
|
||||
|
|
|
|||
|
|
@ -724,7 +724,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
|
||||
var file_pkg_rpc_dfdaemon_dfdaemon_proto_goTypes = []interface{}{
|
||||
var file_pkg_rpc_dfdaemon_dfdaemon_proto_goTypes = []any{
|
||||
(*DownRequest)(nil), // 0: dfdaemon.DownRequest
|
||||
(*DownResult)(nil), // 1: dfdaemon.DownResult
|
||||
(*StatTaskRequest)(nil), // 2: dfdaemon.StatTaskRequest
|
||||
|
|
@ -773,7 +773,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DownRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -785,7 +785,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DownResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -797,7 +797,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*StatTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -809,7 +809,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ImportTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -821,7 +821,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ExportTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -833,7 +833,7 @@ func file_pkg_rpc_dfdaemon_dfdaemon_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_dfdaemon_dfdaemon_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*DeleteTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1074,7 +1074,7 @@ func RegisterDaemonServer(s *grpc.Server, srv DaemonServer) {
|
|||
s.RegisterService(&_Daemon_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Daemon_Download_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Daemon_Download_Handler(srv any, stream grpc.ServerStream) error {
|
||||
m := new(DownRequest)
|
||||
if err := stream.RecvMsg(m); err != nil {
|
||||
return err
|
||||
|
|
@ -1095,7 +1095,7 @@ func (x *daemonDownloadServer) Send(m *DownResult) error {
|
|||
return x.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
func _Daemon_GetPieceTasks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_GetPieceTasks_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(base.PieceTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1107,13 +1107,13 @@ func _Daemon_GetPieceTasks_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/GetPieceTasks",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).GetPieceTasks(ctx, req.(*base.PieceTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_CheckHealth_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_CheckHealth_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(emptypb.Empty)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1125,13 +1125,13 @@ func _Daemon_CheckHealth_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/CheckHealth",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).CheckHealth(ctx, req.(*emptypb.Empty))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_SyncPieceTasks_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Daemon_SyncPieceTasks_Handler(srv any, stream grpc.ServerStream) error {
|
||||
return srv.(DaemonServer).SyncPieceTasks(&daemonSyncPieceTasksServer{stream})
|
||||
}
|
||||
|
||||
|
|
@ -1157,7 +1157,7 @@ func (x *daemonSyncPieceTasksServer) Recv() (*base.PieceTaskRequest, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
func _Daemon_StatTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_StatTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(StatTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1169,13 +1169,13 @@ func _Daemon_StatTask_Handler(srv interface{}, ctx context.Context, dec func(int
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/StatTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).StatTask(ctx, req.(*StatTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_ImportTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_ImportTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(ImportTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1187,13 +1187,13 @@ func _Daemon_ImportTask_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/ImportTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).ImportTask(ctx, req.(*ImportTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_ExportTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_ExportTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(ExportTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1205,13 +1205,13 @@ func _Daemon_ExportTask_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/ExportTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).ExportTask(ctx, req.(*ExportTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Daemon_DeleteTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Daemon_DeleteTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(DeleteTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1223,7 +1223,7 @@ func _Daemon_DeleteTask_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||
Server: srv,
|
||||
FullMethod: "/dfdaemon.Daemon/DeleteTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(DaemonServer).DeleteTask(ctx, req.(*DeleteTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func (m *DownRequest) Validate() error {
|
|||
|
||||
// no validation rules for DisableBackSource
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return DownRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -294,7 +294,7 @@ func (m *StatTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return StatTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -378,7 +378,7 @@ func (m *ImportTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return ImportTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -492,7 +492,7 @@ func (m *ExportTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return ExportTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -584,7 +584,7 @@ func (m *DeleteTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return DeleteTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
|
|||
|
|
@ -1928,7 +1928,7 @@ func file_pkg_rpc_manager_manager_proto_rawDescGZIP() []byte {
|
|||
|
||||
var file_pkg_rpc_manager_manager_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_pkg_rpc_manager_manager_proto_msgTypes = make([]protoimpl.MessageInfo, 18)
|
||||
var file_pkg_rpc_manager_manager_proto_goTypes = []interface{}{
|
||||
var file_pkg_rpc_manager_manager_proto_goTypes = []any{
|
||||
(SourceType)(0), // 0: manager.SourceType
|
||||
(*SecurityGroup)(nil), // 1: manager.SecurityGroup
|
||||
(*SeedPeerCluster)(nil), // 2: manager.SeedPeerCluster
|
||||
|
|
@ -1997,7 +1997,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SecurityGroup); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2009,7 +2009,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SeedPeerCluster); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2021,7 +2021,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SeedPeer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2033,7 +2033,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetSeedPeerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2045,7 +2045,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UpdateSeedPeerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2057,7 +2057,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SchedulerCluster); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2069,7 +2069,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Scheduler); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2081,7 +2081,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetSchedulerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2093,7 +2093,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*UpdateSchedulerRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2105,7 +2105,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ListSchedulersRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2117,7 +2117,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ListSchedulersResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2129,7 +2129,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ObjectStorage); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2141,7 +2141,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[12].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*GetObjectStorageRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2153,7 +2153,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[13].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Bucket); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2165,7 +2165,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[14].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ListBucketsRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2177,7 +2177,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[15].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*ListBucketsResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2189,7 +2189,7 @@ func file_pkg_rpc_manager_manager_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_manager_manager_proto_msgTypes[16].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*KeepAliveRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -2411,7 +2411,7 @@ func RegisterManagerServer(s *grpc.Server, srv ManagerServer) {
|
|||
s.RegisterService(&_Manager_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Manager_GetSeedPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_GetSeedPeer_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(GetSeedPeerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2423,13 +2423,13 @@ func _Manager_GetSeedPeer_Handler(srv interface{}, ctx context.Context, dec func
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/GetSeedPeer",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).GetSeedPeer(ctx, req.(*GetSeedPeerRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_UpdateSeedPeer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_UpdateSeedPeer_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(UpdateSeedPeerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2441,13 +2441,13 @@ func _Manager_UpdateSeedPeer_Handler(srv interface{}, ctx context.Context, dec f
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/UpdateSeedPeer",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).UpdateSeedPeer(ctx, req.(*UpdateSeedPeerRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_GetScheduler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_GetScheduler_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(GetSchedulerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2459,13 +2459,13 @@ func _Manager_GetScheduler_Handler(srv interface{}, ctx context.Context, dec fun
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/GetScheduler",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).GetScheduler(ctx, req.(*GetSchedulerRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_UpdateScheduler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_UpdateScheduler_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(UpdateSchedulerRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2477,13 +2477,13 @@ func _Manager_UpdateScheduler_Handler(srv interface{}, ctx context.Context, dec
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/UpdateScheduler",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).UpdateScheduler(ctx, req.(*UpdateSchedulerRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_ListSchedulers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_ListSchedulers_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(ListSchedulersRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2495,13 +2495,13 @@ func _Manager_ListSchedulers_Handler(srv interface{}, ctx context.Context, dec f
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/ListSchedulers",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).ListSchedulers(ctx, req.(*ListSchedulersRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_GetObjectStorage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_GetObjectStorage_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(GetObjectStorageRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2513,13 +2513,13 @@ func _Manager_GetObjectStorage_Handler(srv interface{}, ctx context.Context, dec
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/GetObjectStorage",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).GetObjectStorage(ctx, req.(*GetObjectStorageRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_ListBuckets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Manager_ListBuckets_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(ListBucketsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -2531,13 +2531,13 @@ func _Manager_ListBuckets_Handler(srv interface{}, ctx context.Context, dec func
|
|||
Server: srv,
|
||||
FullMethod: "/manager.Manager/ListBuckets",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(ManagerServer).ListBuckets(ctx, req.(*ListBucketsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Manager_KeepAlive_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Manager_KeepAlive_Handler(srv any, stream grpc.ServerStream) error {
|
||||
return srv.(ManagerServer).KeepAlive(&managerKeepAliveServer{stream})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ func (m *SeedPeerCluster) Validate() error {
|
|||
|
||||
// no validation rules for Scopes
|
||||
|
||||
if v, ok := interface{}(m.GetSecurityGroup()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetSecurityGroup()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SeedPeerClusterValidationError{
|
||||
field: "SecurityGroup",
|
||||
|
|
@ -222,7 +222,7 @@ func (m *SeedPeer) Validate() error {
|
|||
|
||||
// no validation rules for SeedPeerClusterId
|
||||
|
||||
if v, ok := interface{}(m.GetSeedPeerCluster()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetSeedPeerCluster()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SeedPeerValidationError{
|
||||
field: "SeedPeerCluster",
|
||||
|
|
@ -235,7 +235,7 @@ func (m *SeedPeer) Validate() error {
|
|||
for idx, item := range m.GetSchedulers() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SeedPeerValidationError{
|
||||
field: fmt.Sprintf("Schedulers[%v]", idx),
|
||||
|
|
@ -642,7 +642,7 @@ func (m *SchedulerCluster) Validate() error {
|
|||
|
||||
// no validation rules for Scopes
|
||||
|
||||
if v, ok := interface{}(m.GetSecurityGroup()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetSecurityGroup()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SchedulerClusterValidationError{
|
||||
field: "SecurityGroup",
|
||||
|
|
@ -736,7 +736,7 @@ func (m *Scheduler) Validate() error {
|
|||
|
||||
// no validation rules for SchedulerClusterId
|
||||
|
||||
if v, ok := interface{}(m.GetSchedulerCluster()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetSchedulerCluster()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SchedulerValidationError{
|
||||
field: "SchedulerCluster",
|
||||
|
|
@ -749,7 +749,7 @@ func (m *Scheduler) Validate() error {
|
|||
for idx, item := range m.GetSeedPeers() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SchedulerValidationError{
|
||||
field: fmt.Sprintf("SeedPeers[%v]", idx),
|
||||
|
|
@ -1261,7 +1261,7 @@ func (m *ListSchedulersResponse) Validate() error {
|
|||
for idx, item := range m.GetSchedulers() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return ListSchedulersResponseValidationError{
|
||||
field: fmt.Sprintf("Schedulers[%v]", idx),
|
||||
|
|
@ -1768,7 +1768,7 @@ func (m *ListBucketsResponse) Validate() error {
|
|||
for idx, item := range m.GetBuckets() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return ListBucketsResponseValidationError{
|
||||
field: fmt.Sprintf("Buckets[%v]", idx),
|
||||
|
|
|
|||
|
|
@ -1464,7 +1464,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_pkg_rpc_scheduler_scheduler_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_pkg_rpc_scheduler_scheduler_proto_goTypes = []interface{}{
|
||||
var file_pkg_rpc_scheduler_scheduler_proto_goTypes = []any{
|
||||
(*PeerTaskRequest)(nil), // 0: scheduler.PeerTaskRequest
|
||||
(*RegisterResult)(nil), // 1: scheduler.RegisterResult
|
||||
(*SinglePiece)(nil), // 2: scheduler.SinglePiece
|
||||
|
|
@ -1536,7 +1536,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[0].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1548,7 +1548,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[1].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*RegisterResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1560,7 +1560,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[2].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*SinglePiece); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1572,7 +1572,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[3].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerHost); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1584,7 +1584,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[4].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PieceResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1596,7 +1596,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[5].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerPacket); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1608,7 +1608,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[6].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerResult); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1620,7 +1620,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[7].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerTarget); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1632,7 +1632,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[8].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*StatTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1644,7 +1644,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[9].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*Task); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1656,7 +1656,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[10].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*AnnounceTaskRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1668,7 +1668,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[11].Exporter = func(v any, i int) any {
|
||||
switch v := v.(*PeerPacket_DestPeer); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
|
|
@ -1681,7 +1681,7 @@ func file_pkg_rpc_scheduler_scheduler_proto_init() {
|
|||
}
|
||||
}
|
||||
}
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[1].OneofWrappers = []interface{}{
|
||||
file_pkg_rpc_scheduler_scheduler_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*RegisterResult_SinglePiece)(nil),
|
||||
(*RegisterResult_PieceContent)(nil),
|
||||
}
|
||||
|
|
@ -1858,7 +1858,7 @@ func RegisterSchedulerServer(s *grpc.Server, srv SchedulerServer) {
|
|||
s.RegisterService(&_Scheduler_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Scheduler_RegisterPeerTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Scheduler_RegisterPeerTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(PeerTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1870,13 +1870,13 @@ func _Scheduler_RegisterPeerTask_Handler(srv interface{}, ctx context.Context, d
|
|||
Server: srv,
|
||||
FullMethod: "/scheduler.Scheduler/RegisterPeerTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SchedulerServer).RegisterPeerTask(ctx, req.(*PeerTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Scheduler_ReportPieceResult_Handler(srv interface{}, stream grpc.ServerStream) error {
|
||||
func _Scheduler_ReportPieceResult_Handler(srv any, stream grpc.ServerStream) error {
|
||||
return srv.(SchedulerServer).ReportPieceResult(&schedulerReportPieceResultServer{stream})
|
||||
}
|
||||
|
||||
|
|
@ -1902,7 +1902,7 @@ func (x *schedulerReportPieceResultServer) Recv() (*PieceResult, error) {
|
|||
return m, nil
|
||||
}
|
||||
|
||||
func _Scheduler_ReportPeerResult_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Scheduler_ReportPeerResult_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(PeerResult)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1914,13 +1914,13 @@ func _Scheduler_ReportPeerResult_Handler(srv interface{}, ctx context.Context, d
|
|||
Server: srv,
|
||||
FullMethod: "/scheduler.Scheduler/ReportPeerResult",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SchedulerServer).ReportPeerResult(ctx, req.(*PeerResult))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Scheduler_LeaveTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Scheduler_LeaveTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(PeerTarget)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1932,13 +1932,13 @@ func _Scheduler_LeaveTask_Handler(srv interface{}, ctx context.Context, dec func
|
|||
Server: srv,
|
||||
FullMethod: "/scheduler.Scheduler/LeaveTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SchedulerServer).LeaveTask(ctx, req.(*PeerTarget))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Scheduler_StatTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Scheduler_StatTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(StatTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1950,13 +1950,13 @@ func _Scheduler_StatTask_Handler(srv interface{}, ctx context.Context, dec func(
|
|||
Server: srv,
|
||||
FullMethod: "/scheduler.Scheduler/StatTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SchedulerServer).StatTask(ctx, req.(*StatTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Scheduler_AnnounceTask_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
func _Scheduler_AnnounceTask_Handler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
|
||||
in := new(AnnounceTaskRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1968,7 +1968,7 @@ func _Scheduler_AnnounceTask_Handler(srv interface{}, ctx context.Context, dec f
|
|||
Server: srv,
|
||||
FullMethod: "/scheduler.Scheduler/AnnounceTask",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
handler := func(ctx context.Context, req any) (any, error) {
|
||||
return srv.(SchedulerServer).AnnounceTask(ctx, req.(*AnnounceTaskRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func (m *PeerTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PeerTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -96,7 +96,7 @@ func (m *PeerTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PeerTaskRequestValidationError{
|
||||
field: "PeerHost",
|
||||
|
|
@ -106,7 +106,7 @@ func (m *PeerTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PeerTaskRequestValidationError{
|
||||
field: "HostLoad",
|
||||
|
|
@ -208,7 +208,7 @@ func (m *RegisterResult) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return RegisterResultValidationError{
|
||||
field: "ExtendAttribute",
|
||||
|
|
@ -222,7 +222,7 @@ func (m *RegisterResult) Validate() error {
|
|||
|
||||
case *RegisterResult_SinglePiece:
|
||||
|
||||
if v, ok := interface{}(m.GetSinglePiece()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetSinglePiece()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return RegisterResultValidationError{
|
||||
field: "SinglePiece",
|
||||
|
|
@ -316,7 +316,7 @@ func (m *SinglePiece) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return SinglePieceValidationError{
|
||||
field: "PieceInfo",
|
||||
|
|
@ -545,7 +545,7 @@ func (m *PieceResult) Validate() error {
|
|||
|
||||
// no validation rules for DstPid
|
||||
|
||||
if v, ok := interface{}(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPieceInfo()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PieceResultValidationError{
|
||||
field: "PieceInfo",
|
||||
|
|
@ -563,7 +563,7 @@ func (m *PieceResult) Validate() error {
|
|||
|
||||
// no validation rules for Code
|
||||
|
||||
if v, ok := interface{}(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetHostLoad()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PieceResultValidationError{
|
||||
field: "HostLoad",
|
||||
|
|
@ -575,7 +575,7 @@ func (m *PieceResult) Validate() error {
|
|||
|
||||
// no validation rules for FinishedCount
|
||||
|
||||
if v, ok := interface{}(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetExtendAttribute()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PieceResultValidationError{
|
||||
field: "ExtendAttribute",
|
||||
|
|
@ -670,7 +670,7 @@ func (m *PeerPacket) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetMainPeer()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetMainPeer()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PeerPacketValidationError{
|
||||
field: "MainPeer",
|
||||
|
|
@ -683,7 +683,7 @@ func (m *PeerPacket) Validate() error {
|
|||
for idx, item := range m.GetStealPeers() {
|
||||
_, _ = idx, item
|
||||
|
||||
if v, ok := interface{}(item).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(item).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return PeerPacketValidationError{
|
||||
field: fmt.Sprintf("StealPeers[%v]", idx),
|
||||
|
|
@ -1170,7 +1170,7 @@ func (m *AnnounceTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetUrlMeta()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return AnnounceTaskRequestValidationError{
|
||||
field: "UrlMeta",
|
||||
|
|
@ -1180,7 +1180,7 @@ func (m *AnnounceTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPeerHost()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return AnnounceTaskRequestValidationError{
|
||||
field: "PeerHost",
|
||||
|
|
@ -1197,7 +1197,7 @@ func (m *AnnounceTaskRequest) Validate() error {
|
|||
}
|
||||
}
|
||||
|
||||
if v, ok := interface{}(m.GetPiecePacket()).(interface{ Validate() error }); ok {
|
||||
if v, ok := any(m.GetPiecePacket()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return AnnounceTaskRequestValidationError{
|
||||
field: "PiecePacket",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func DefaultServerOptions() []grpc.ServerOption {
|
|||
}
|
||||
}
|
||||
|
||||
func streamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
func streamServerInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
err := handler(srv, ss)
|
||||
if err != nil {
|
||||
err = convertServerError(err)
|
||||
|
|
@ -76,7 +76,7 @@ func streamServerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.S
|
|||
return err
|
||||
}
|
||||
|
||||
func unaryServerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
func unaryServerInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
|
||||
m, err := handler(ctx, req)
|
||||
if err != nil {
|
||||
err = convertServerError(err)
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type requestMatcher struct {
|
|||
}
|
||||
|
||||
// Matches returns whether x is a match.
|
||||
func (req requestMatcher) Matches(x interface{}) bool {
|
||||
func (req requestMatcher) Matches(x any) bool {
|
||||
return x.(*Request).URL.String() == req.url
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ func (c *client) GetLastModified(request *source.Request) (int64, error) {
|
|||
panic("implement me")
|
||||
}
|
||||
|
||||
func DragonflyPluginInit(option map[string]string) (interface{}, map[string]string, error) {
|
||||
func DragonflyPluginInit(option map[string]string) (any, map[string]string, error) {
|
||||
return &client{}, map[string]string{
|
||||
"type": "resource",
|
||||
"name": "dfs",
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import (
|
|||
)
|
||||
|
||||
// StructToMap coverts struct to map.
|
||||
func StructToMap(t interface{}) (map[string]interface{}, error) {
|
||||
var m map[string]interface{}
|
||||
func StructToMap(t any) (map[string]any, error) {
|
||||
var m map[string]any
|
||||
b, err := json.Marshal(t)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ import (
|
|||
func TestStructToMap(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
s interface{}
|
||||
expect func(*testing.T, map[string]interface{}, error)
|
||||
s any
|
||||
expect func(*testing.T, map[string]any, error)
|
||||
}{
|
||||
{
|
||||
name: "conver struct to map",
|
||||
|
|
@ -37,9 +37,9 @@ func TestStructToMap(t *testing.T) {
|
|||
Name: "foo",
|
||||
Age: 18,
|
||||
},
|
||||
expect: func(t *testing.T, m map[string]interface{}, err error) {
|
||||
expect: func(t *testing.T, m map[string]any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(m, map[string]interface{}{
|
||||
assert.Equal(m, map[string]any{
|
||||
"Name": "foo",
|
||||
"Age": float64(18),
|
||||
})
|
||||
|
|
@ -48,7 +48,7 @@ func TestStructToMap(t *testing.T) {
|
|||
{
|
||||
name: "conver string to map failed",
|
||||
s: "foo",
|
||||
expect: func(t *testing.T, m map[string]interface{}, err error) {
|
||||
expect: func(t *testing.T, m map[string]any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualError(err, "json: cannot unmarshal string into Go value of type map[string]interface {}")
|
||||
},
|
||||
|
|
@ -56,7 +56,7 @@ func TestStructToMap(t *testing.T) {
|
|||
{
|
||||
name: "conver number to map failed",
|
||||
s: 1,
|
||||
expect: func(t *testing.T, m map[string]interface{}, err error) {
|
||||
expect: func(t *testing.T, m map[string]any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.EqualError(err, "json: cannot unmarshal number into Go value of type map[string]interface {}")
|
||||
},
|
||||
|
|
@ -64,9 +64,9 @@ func TestStructToMap(t *testing.T) {
|
|||
{
|
||||
name: "conver nil to map",
|
||||
s: nil,
|
||||
expect: func(t *testing.T, m map[string]interface{}, err error) {
|
||||
expect: func(t *testing.T, m map[string]any, err error) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(m, map[string]interface{}(nil))
|
||||
assert.Equal(m, map[string]any(nil))
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ func parseSize(fsize string) (Bytes, error) {
|
|||
return ToBytes(num) * unit, nil
|
||||
}
|
||||
|
||||
func (f Bytes) MarshalYAML() (interface{}, error) {
|
||||
func (f Bytes) MarshalYAML() (any, error) {
|
||||
result := f.String()
|
||||
return result, nil
|
||||
}
|
||||
|
|
@ -143,8 +143,8 @@ func (f *Bytes) UnmarshalYAML(node *yaml.Node) error {
|
|||
return f.unmarshal(yaml.Unmarshal, []byte(node.Value))
|
||||
}
|
||||
|
||||
func (f *Bytes) unmarshal(unmarshal func(in []byte, out interface{}) (err error), b []byte) error {
|
||||
var v interface{}
|
||||
func (f *Bytes) unmarshal(unmarshal func(in []byte, out any) (err error), b []byte) error {
|
||||
var v any
|
||||
if err := unmarshal(b, &v); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func TestConfig_Load(t *testing.T) {
|
|||
|
||||
schedulerConfigYAML := &Config{}
|
||||
contentYAML, _ := os.ReadFile("./testdata/scheduler.yaml")
|
||||
var dataYAML map[string]interface{}
|
||||
var dataYAML map[string]any
|
||||
if err := yaml.Unmarshal(contentYAML, &dataYAML); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ func newManagerClient(client managerclient.Client, cfg *Config) dc.ManagerClient
|
|||
}
|
||||
}
|
||||
|
||||
func (mc *managerClient) Get() (interface{}, error) {
|
||||
func (mc *managerClient) Get() (any, error) {
|
||||
scheduler, err := mc.GetScheduler(&manager.GetSchedulerRequest{
|
||||
HostName: mc.config.Server.Host,
|
||||
SourceType: manager.SourceType_SCHEDULER_SOURCE,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func New(cfg *config.Config, resource resource.Resource) (Job, error) {
|
|||
config: cfg,
|
||||
}
|
||||
|
||||
namedJobFuncs := map[string]interface{}{
|
||||
namedJobFuncs := map[string]any{
|
||||
internaljob.PreheatJob: t.preheat,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func (h *Host) DeletePeer(key string) {
|
|||
|
||||
// LeavePeers set peer state to PeerStateLeave.
|
||||
func (h *Host) LeavePeers() {
|
||||
h.Peers.Range(func(_, value interface{}) bool {
|
||||
h.Peers.Range(func(_, value any) bool {
|
||||
if peer, ok := value.(*Peer); ok {
|
||||
if err := peer.FSM.Event(PeerEventDownloadFailed); err != nil {
|
||||
peer.Log.Errorf("peer fsm event failed: %s", err.Error())
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (h *hostManager) Delete(key string) {
|
|||
}
|
||||
|
||||
func (h *hostManager) RunGC() error {
|
||||
h.Map.Range(func(_, value interface{}) bool {
|
||||
h.Map.Range(func(_, value any) bool {
|
||||
host := value.(*Host)
|
||||
elapsed := time.Since(host.UpdateAt.Load())
|
||||
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ func TestHost_LeavePeers(t *testing.T) {
|
|||
host.StorePeer(mockPeer)
|
||||
assert.Equal(host.PeerCount.Load(), int32(1))
|
||||
host.LeavePeers()
|
||||
host.Peers.Range(func(_, value interface{}) bool {
|
||||
host.Peers.Range(func(_, value any) bool {
|
||||
peer := value.(*Peer)
|
||||
assert.True(peer.FSM.Is(PeerStateLeave))
|
||||
return true
|
||||
|
|
@ -351,7 +351,7 @@ func TestHost_LeavePeers(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
assert.Equal(host.PeerCount.Load(), int32(0))
|
||||
host.LeavePeers()
|
||||
host.Peers.Range(func(_, value interface{}) bool {
|
||||
host.Peers.Range(func(_, value any) bool {
|
||||
assert.Fail("host peers is not empty")
|
||||
return true
|
||||
})
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func (p *peerManager) Delete(key string) {
|
|||
}
|
||||
|
||||
func (p *peerManager) RunGC() error {
|
||||
p.Map.Range(func(_, value interface{}) bool {
|
||||
p.Map.Range(func(_, value any) bool {
|
||||
peer := value.(*Peer)
|
||||
elapsed := time.Since(peer.UpdateAt.Load())
|
||||
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ func (t *Task) DeletePeer(key string) {
|
|||
// HasAvailablePeer returns whether there is an available peer.
|
||||
func (t *Task) HasAvailablePeer() bool {
|
||||
var hasAvailablePeer bool
|
||||
t.Peers.Range(func(_, v interface{}) bool {
|
||||
t.Peers.Range(func(_, v any) bool {
|
||||
peer, ok := v.(*Peer)
|
||||
if !ok {
|
||||
return true
|
||||
|
|
@ -237,7 +237,7 @@ func (t *Task) HasAvailablePeer() bool {
|
|||
// LoadSeedPeer return latest seed peer in peers sync map.
|
||||
func (t *Task) LoadSeedPeer() (*Peer, bool) {
|
||||
var peers []*Peer
|
||||
t.Peers.Range(func(_, v interface{}) bool {
|
||||
t.Peers.Range(func(_, v any) bool {
|
||||
peer, ok := v.(*Peer)
|
||||
if !ok {
|
||||
return true
|
||||
|
|
@ -326,7 +326,7 @@ func (t *Task) CanBackToSource() bool {
|
|||
|
||||
// NotifyPeers notify all peers in the task with the state code.
|
||||
func (t *Task) NotifyPeers(code base.Code, event string) {
|
||||
t.Peers.Range(func(_, value interface{}) bool {
|
||||
t.Peers.Range(func(_, value any) bool {
|
||||
peer := value.(*Peer)
|
||||
if peer.FSM.Is(PeerStateRunning) {
|
||||
stream, ok := peer.LoadStream()
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (t *taskManager) Delete(key string) {
|
|||
}
|
||||
|
||||
func (t *taskManager) RunGC() error {
|
||||
t.Map.Range(func(_, value interface{}) bool {
|
||||
t.Map.Range(func(_, value any) bool {
|
||||
task := value.(*Task)
|
||||
elapsed := time.Since(task.UpdateAt.Load())
|
||||
|
||||
|
|
|
|||
|
|
@ -44,11 +44,11 @@ var (
|
|||
func TestRPCServer_New(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
expect func(t *testing.T, s interface{})
|
||||
expect func(t *testing.T, s any)
|
||||
}{
|
||||
{
|
||||
name: "new server",
|
||||
expect: func(t *testing.T, s interface{}) {
|
||||
expect: func(t *testing.T, s any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(s).Elem().Name(), "Server")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -58,11 +58,11 @@ var (
|
|||
func TestEvaluatorBase_NewEvaluatorBase(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
expect func(t *testing.T, e interface{})
|
||||
expect func(t *testing.T, e any)
|
||||
}{
|
||||
{
|
||||
name: "new evaluator base",
|
||||
expect: func(t *testing.T, e interface{}) {
|
||||
expect: func(t *testing.T, e any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(e).Elem().Name(), "evaluatorBase")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,12 +28,12 @@ func TestEvaluator_New(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
algorithm string
|
||||
expect func(t *testing.T, e interface{})
|
||||
expect func(t *testing.T, e any)
|
||||
}{
|
||||
{
|
||||
name: "new evaluator with default algorithm",
|
||||
algorithm: "default",
|
||||
expect: func(t *testing.T, e interface{}) {
|
||||
expect: func(t *testing.T, e any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(e).Elem().Name(), "evaluatorBase")
|
||||
},
|
||||
|
|
@ -41,7 +41,7 @@ func TestEvaluator_New(t *testing.T) {
|
|||
{
|
||||
name: "new evaluator with machine learning algorithm",
|
||||
algorithm: "ml",
|
||||
expect: func(t *testing.T, e interface{}) {
|
||||
expect: func(t *testing.T, e any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(e).Elem().Name(), "evaluatorBase")
|
||||
},
|
||||
|
|
@ -49,7 +49,7 @@ func TestEvaluator_New(t *testing.T) {
|
|||
{
|
||||
name: "new evaluator with plugin",
|
||||
algorithm: "plugin",
|
||||
expect: func(t *testing.T, e interface{}) {
|
||||
expect: func(t *testing.T, e any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(e).Elem().Name(), "evaluatorBase")
|
||||
},
|
||||
|
|
@ -57,7 +57,7 @@ func TestEvaluator_New(t *testing.T) {
|
|||
{
|
||||
name: "new evaluator with empty string",
|
||||
algorithm: "",
|
||||
expect: func(t *testing.T, e interface{}) {
|
||||
expect: func(t *testing.T, e any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(e).Elem().Name(), "evaluatorBase")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -28,6 +28,6 @@ func (e *evaluator) IsBadNode(peer *resource.Peer) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func DragonflyPluginInit(option map[string]string) (interface{}, map[string]string, error) {
|
||||
func DragonflyPluginInit(option map[string]string) (any, map[string]string, error) {
|
||||
return &evaluator{}, map[string]string{"type": "scheduler", "name": "evaluator"}, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ func (s *scheduler) filterCandidateParents(peer *resource.Peer, blocklist set.Sa
|
|||
var candidateParents []*resource.Peer
|
||||
var candidateParentIDs []string
|
||||
var n int
|
||||
peer.Task.Peers.Range(func(_, value interface{}) bool {
|
||||
peer.Task.Peers.Range(func(_, value any) bool {
|
||||
if n > filterParentLimit {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,12 +93,12 @@ func TestScheduler_New(t *testing.T) {
|
|||
tests := []struct {
|
||||
name string
|
||||
pluginDir string
|
||||
expect func(t *testing.T, s interface{})
|
||||
expect func(t *testing.T, s any)
|
||||
}{
|
||||
{
|
||||
name: "new scheduler",
|
||||
pluginDir: "bar",
|
||||
expect: func(t *testing.T, s interface{}) {
|
||||
expect: func(t *testing.T, s any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(s).Elem().Name(), "scheduler")
|
||||
},
|
||||
|
|
@ -106,7 +106,7 @@ func TestScheduler_New(t *testing.T) {
|
|||
{
|
||||
name: "new scheduler with empty pluginDir",
|
||||
pluginDir: "",
|
||||
expect: func(t *testing.T, s interface{}) {
|
||||
expect: func(t *testing.T, s any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(s).Elem().Name(), "scheduler")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -476,7 +476,7 @@ func (s *Service) LeaveTask(ctx context.Context, req *rpcscheduler.PeerTarget) e
|
|||
return dferrors.New(base.Code_SchedTaskStatusError, msg)
|
||||
}
|
||||
|
||||
peer.Children.Range(func(_, value interface{}) bool {
|
||||
peer.Children.Range(func(_, value any) bool {
|
||||
child, ok := value.(*resource.Peer)
|
||||
if !ok {
|
||||
return true
|
||||
|
|
@ -726,7 +726,7 @@ func (s *Service) handlePeerFail(ctx context.Context, peer *resource.Peer) {
|
|||
}
|
||||
|
||||
// Reschedule a new parent to children of peer to exclude the current failed peer.
|
||||
peer.Children.Range(func(_, value interface{}) bool {
|
||||
peer.Children.Range(func(_, value any) bool {
|
||||
child, ok := value.(*resource.Peer)
|
||||
if !ok {
|
||||
return true
|
||||
|
|
@ -752,7 +752,7 @@ func (s *Service) handleLegacySeedPeer(ctx context.Context, peer *resource.Peer)
|
|||
}
|
||||
|
||||
// Reschedule a new parent to children of peer to exclude the current failed peer.
|
||||
peer.Children.Range(func(_, value interface{}) bool {
|
||||
peer.Children.Range(func(_, value any) bool {
|
||||
child, ok := value.(*resource.Peer)
|
||||
if !ok {
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -102,11 +102,11 @@ var (
|
|||
func TestService_New(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
expect func(t *testing.T, s interface{})
|
||||
expect func(t *testing.T, s any)
|
||||
}{
|
||||
{
|
||||
name: "new service",
|
||||
expect: func(t *testing.T, s interface{}) {
|
||||
expect: func(t *testing.T, s any) {
|
||||
assert := assert.New(t)
|
||||
assert.Equal(reflect.TypeOf(s).Elem().Name(), "Service")
|
||||
},
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func (p *PodExec) Command(arg ...string) *exec.Cmd {
|
|||
return KubeCtlCommand(extArgs...)
|
||||
}
|
||||
|
||||
func (p *PodExec) CurlCommand(method string, header map[string]string, data map[string]interface{}, target string) *exec.Cmd {
|
||||
func (p *PodExec) CurlCommand(method string, header map[string]string, data map[string]any, target string) *exec.Cmd {
|
||||
extArgs := []string{"/usr/bin/curl", target, "-s"}
|
||||
if method != "" {
|
||||
extArgs = append(extArgs, "-X", method)
|
||||
|
|
|
|||
Loading…
Reference in New Issue