Browse Source

Merge branch 'master' into feature_rzs

pull/45/head
JeshuaRen 1 year ago
parent
commit
0a8bc33909
4 changed files with 10 additions and 7 deletions
  1. +1
    -0
      consts/errorcode/error_code.go
  2. +3
    -1
      pkgs/cmdtrie/command_trie.go
  3. +5
    -5
      pkgs/mq/client.go
  4. +1
    -1
      sdks/storage/models.go

+ 1
- 0
consts/errorcode/error_code.go View File

@@ -3,6 +3,7 @@ package errorcode
const ( const (
OK = "OK" OK = "OK"
OperationFailed = "OperationFailed" OperationFailed = "OperationFailed"
DataNotFound = "DataNotFound"
BadArgument = "BadArgument" BadArgument = "BadArgument"
TaskNotFound = "TaskNotFound" TaskNotFound = "TaskNotFound"
) )

+ 3
- 1
pkgs/cmdtrie/command_trie.go View File

@@ -10,6 +10,8 @@ import (
"gitlink.org.cn/cloudream/common/utils/reflect2" "gitlink.org.cn/cloudream/common/utils/reflect2"
) )


var ErrCommandNotFound = fmt.Errorf("command not found")

type ExecuteOption struct { type ExecuteOption struct {
ReplaceEmptyArrayWithNil bool // 如果最后一个参数是空数组,则调用命令的时候传递nil参数 ReplaceEmptyArrayWithNil bool // 如果最后一个参数是空数组,则调用命令的时候传递nil参数
} }
@@ -178,7 +180,7 @@ func (t *anyCommandTrie) findCommand(cmdWords []string, argWords []string) (*com
}) })


if cmd == nil { if cmd == nil {
return nil, nil, fmt.Errorf("command not found")
return nil, nil, ErrCommandNotFound
} }
return cmd, argWords, nil return cmd, argWords, nil
} }


+ 5
- 5
pkgs/mq/client.go View File

@@ -22,12 +22,12 @@ const (
var ErrWaitResponseTimeout = fmt.Errorf("wait response timeout") var ErrWaitResponseTimeout = fmt.Errorf("wait response timeout")


type CodeMessageError struct { type CodeMessageError struct {
code string
message string
Code string
Message string
} }


func (e *CodeMessageError) Error() string { func (e *CodeMessageError) Error() string {
return fmt.Sprintf("code: %s, message: %s", e.code, e.message)
return fmt.Sprintf("code: %s, message: %s", e.Code, e.Message)
} }


type SendOption struct { type SendOption struct {
@@ -315,8 +315,8 @@ func Request[TSvc any, TReq MessageBody, TResp MessageBody](_ func(svc TSvc, msg
errCode, errMsg := resp.GetCodeMessage() errCode, errMsg := resp.GetCodeMessage()
if errCode != errorcode.OK { if errCode != errorcode.OK {
return defRet, &CodeMessageError{ return defRet, &CodeMessageError{
code: errCode,
message: errMsg,
Code: errCode,
Message: errMsg,
} }
} }




+ 1
- 1
sdks/storage/models.go View File

@@ -71,7 +71,7 @@ func (b *RepRedundancy) Value() (driver.Value, error) {
return serder.ObjectToJSONEx[Redundancy](b) return serder.ObjectToJSONEx[Redundancy](b)
} }


var DefaultECRedundancy = *NewECRedundancy(3, 5, 1024*1024*5)
var DefaultECRedundancy = *NewECRedundancy(2, 3, 1024*1024*5)


type ECRedundancy struct { type ECRedundancy struct {
serder.Metadata `union:"ec"` serder.Metadata `union:"ec"`


Loading…
Cancel
Save