fix etcd prefix
This commit is contained in:
parent
79363aabf0
commit
87ea785119
|
@ -19,6 +19,8 @@ func parseArgs(cmd string) {
|
||||||
switch cmd {
|
switch cmd {
|
||||||
case "-v", "--v", "-version", "--version":
|
case "-v", "--v", "-version", "--version":
|
||||||
versionCmd()
|
versionCmd()
|
||||||
|
case "--json":
|
||||||
|
versionCmdJson()
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
@ -28,3 +30,7 @@ func versionCmd() {
|
||||||
fmt.Printf("[Blocks Service: %s] Version: %s \n", vars.ServiceKey, vars.VERSION)
|
fmt.Printf("[Blocks Service: %s] Version: %s \n", vars.ServiceKey, vars.VERSION)
|
||||||
fmt.Printf("[Blocks Service: %s] Compile: %s by %s build.\n", vars.ServiceKey, vars.GO_VERSION, vars.BUILD_TIME)
|
fmt.Printf("[Blocks Service: %s] Compile: %s by %s build.\n", vars.ServiceKey, vars.GO_VERSION, vars.BUILD_TIME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func versionCmdJson() {
|
||||||
|
fmt.Printf("{\"version\":\"%s\",\"build_time\":\"%s\"}\n", vars.VERSION, vars.BUILD_TIME)
|
||||||
|
}
|
||||||
|
|
|
@ -2,13 +2,13 @@ package exception
|
||||||
|
|
||||||
// jwt custom error code ,begin:200
|
// jwt custom error code ,begin:200
|
||||||
var (
|
var (
|
||||||
ErrAuthPasswd = ErrorJson(201, "Password Error")
|
ErrAuthPasswd = Errorf(201, "Password Error")
|
||||||
ErrAuthNotFound = ErrorJson(202, "Auth Token Not Found")
|
ErrAuthNotFound = Errorf(202, "Auth Token Not Found")
|
||||||
ErrAuthParseFail = ErrorJson(203, "Auth Parse Fail")
|
ErrAuthParseFail = Errorf(203, "Auth Parse Fail")
|
||||||
ErrAuthId = ErrorJson(204, "Auth Id Not Passed")
|
ErrAuthId = Errorf(204, "Auth Id Not Passed")
|
||||||
ErrAuthIdentity = ErrorJson(205, "Auth Identity Not Passed")
|
ErrAuthIdentity = Errorf(205, "Auth Identity Not Passed")
|
||||||
ErrAuthTokenChanged = ErrorJson(206, "Auth Token Changed")
|
ErrAuthTokenChanged = Errorf(206, "Auth Token Changed")
|
||||||
ErrAuthIdType = ErrorJson(207, "Auth Id Type Error")
|
ErrAuthIdType = Errorf(207, "Auth Id Type Error")
|
||||||
ErrAuthExpire = ErrorJson(208, "Auth Token Expire")
|
ErrAuthExpire = Errorf(208, "Auth Token Expire")
|
||||||
ErrAuthClient = ErrorJson(208, "Auth Token Client Not Passed")
|
ErrAuthClient = Errorf(208, "Auth Token Client Not Passed")
|
||||||
)
|
)
|
||||||
|
|
|
@ -2,9 +2,9 @@ package exception
|
||||||
|
|
||||||
// db custom error code ,begin:300
|
// db custom error code ,begin:300
|
||||||
var (
|
var (
|
||||||
ErrDBFatal = ErrorJson(300, "DB Fatal error")
|
ErrDBFatal = Errorf(300, "DB Fatal error")
|
||||||
ErrCacheFatal = ErrorJson(301, "Cache Fatal error")
|
ErrCacheFatal = Errorf(301, "Cache Fatal error")
|
||||||
ErrEtcdFatal = ErrorJson(302, "Etcd Fatal error")
|
ErrEtcdFatal = Errorf(302, "Etcd Fatal error")
|
||||||
ErrElasticFatal = ErrorJson(303, "Elastic Fatal error")
|
ErrElasticFatal = Errorf(303, "Elastic Fatal error")
|
||||||
ErrBlocksMQFatal = ErrorJson(304, "BlocksMQ Fatal error")
|
ErrBlocksMQFatal = Errorf(304, "BlocksMQ Fatal error")
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,27 +9,27 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// google grpc error status.
|
// google grpc error status.
|
||||||
OK = ErrorJson(0, "OK")
|
OK = Errorf(0, "OK")
|
||||||
ErrCanceled = ErrorJson(1, "Canceled")
|
ErrCanceled = Errorf(1, "Canceled")
|
||||||
ErrUnknown = ErrorJson(2, "Unknown")
|
ErrUnknown = Errorf(2, "Unknown")
|
||||||
ErrInvalidArgument = ErrorJson(3, "Invalid Argument")
|
ErrInvalidArgument = Errorf(3, "Invalid Argument")
|
||||||
ErrDeadlineExceeded = ErrorJson(4, "Deadline Exceeded")
|
ErrDeadlineExceeded = Errorf(4, "Deadline Exceeded")
|
||||||
ErrNotFound = ErrorJson(5, "Not Found")
|
ErrNotFound = Errorf(5, "Not Found")
|
||||||
ErrAlreadyExists = ErrorJson(6, "Already Exists")
|
ErrAlreadyExists = Errorf(6, "Already Exists")
|
||||||
ErrPermissionDenied = ErrorJson(7, "Permission Denied")
|
ErrPermissionDenied = Errorf(7, "Permission Denied")
|
||||||
ErrResourceExhausted = ErrorJson(8, "Resource Exhausted")
|
ErrResourceExhausted = Errorf(8, "Resource Exhausted")
|
||||||
ErrFailedPrecondition = ErrorJson(9, "Failed Precondition")
|
ErrFailedPrecondition = Errorf(9, "Failed Precondition")
|
||||||
ErrAborted = ErrorJson(10, "Aborted")
|
ErrAborted = Errorf(10, "Aborted")
|
||||||
ErrOutOfRange = ErrorJson(11, "Out Of Range")
|
ErrOutOfRange = Errorf(11, "Out Of Range")
|
||||||
ErrUnimplemented = ErrorJson(12, "Unimplemented")
|
ErrUnimplemented = Errorf(12, "Unimplemented")
|
||||||
ErrInternal = ErrorJson(13, "Internal")
|
ErrInternal = Errorf(13, "Internal")
|
||||||
ErrUnavailable = ErrorJson(14, "Unavailable")
|
ErrUnavailable = Errorf(14, "Unavailable")
|
||||||
ErrDataLoss = ErrorJson(15, "Data Loss")
|
ErrDataLoss = Errorf(15, "Data Loss")
|
||||||
ErrUnauthenticated = ErrorJson(16, "Unauthenticated")
|
ErrUnauthenticated = Errorf(16, "Unauthenticated")
|
||||||
ErrJSONMarshal = ErrorJson(17, "Marshal JSON")
|
ErrJSONMarshal = Errorf(17, "Marshal JSON")
|
||||||
ErrJSONUnmarshal = ErrorJson(18, "Unmarshal JSON")
|
ErrJSONUnmarshal = Errorf(18, "Unmarshal JSON")
|
||||||
|
|
||||||
ErrSmsCode = ErrorJson(20, "SMS Code Invalid")
|
ErrSmsCode = Errorf(20, "SMS Code Invalid")
|
||||||
|
|
||||||
// coustom error status
|
// coustom error status
|
||||||
)
|
)
|
||||||
|
@ -41,7 +41,3 @@ func Error(c uint32, msg string) error {
|
||||||
func Errorf(c uint32, format string, a ...interface{}) error {
|
func Errorf(c uint32, format string, a ...interface{}) error {
|
||||||
return status.New(codes.Code(c), fmt.Sprintf(format, a...)).Err()
|
return status.New(codes.Code(c), fmt.Sprintf(format, a...)).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func ErrorJson(c uint32, msg string) error {
|
|
||||||
return status.New(codes.Code(c), fmt.Sprintf(`{ "Code": %d, "Msg": "%s" }`, c, msg)).Err()
|
|
||||||
}
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ package exception
|
||||||
|
|
||||||
// mq custom error code ,begin:900
|
// mq custom error code ,begin:900
|
||||||
var (
|
var (
|
||||||
ErrMQClient = ErrorJson(900, "MQ Connect Error")
|
ErrMQClient = Errorf(900, "MQ Connect Error")
|
||||||
ErrMQDispatch = ErrorJson(901, "MQ Dispatch Error")
|
ErrMQDispatch = Errorf(901, "MQ Dispatch Error")
|
||||||
ErrMQProducer = ErrorJson(902, "MQ Producer Error")
|
ErrMQProducer = Errorf(902, "MQ Producer Error")
|
||||||
ErrMQConsumer = ErrorJson(902, "MQ Consumer Error")
|
ErrMQConsumer = Errorf(902, "MQ Consumer Error")
|
||||||
ErrMQInternal = ErrorJson(903, "MQ Internal Error")
|
ErrMQInternal = Errorf(903, "MQ Internal Error")
|
||||||
ErrMQStorage = ErrorJson(904, "MQ Storage Error")
|
ErrMQStorage = Errorf(904, "MQ Storage Error")
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue