1 Star 0 Fork 0

h79 / goutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
error.go 639 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2023-12-12 13:15 . rpc log
package rpc
import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
func WithStatus(err error) *status.Status {
if st, ok := status.FromError(err); ok {
return st
}
return nil
}
func IsDeadlineExceeded(s *status.Status) bool {
return s != nil && s.Code() == codes.DeadlineExceeded
}
func IsUnimplemented(s *status.Status) bool {
return s != nil && s.Code() == codes.Unimplemented
}
func IsClosed(s *status.Status) bool {
return s != nil && s.Code() == codes.Canceled
}
func IsNeedAlarm(s *status.Status) bool {
return s != nil && (s.Code() == codes.DeadlineExceeded || s.Code() == codes.Unimplemented)
}
Go
1
https://gitee.com/h79/goutils.git
git@gitee.com:h79/goutils.git
h79
goutils
goutils
v1.20.57

搜索帮助