ws update

This commit is contained in:
Gordon
2023-03-23 15:56:47 +08:00
parent a5380a971b
commit 393dfa5902
4 changed files with 24 additions and 5 deletions
+1
View File
@@ -278,6 +278,7 @@ const Token = "token"
const RpcCustomHeader = "customHeader" // rpc中间件自定义ctx参数
const CheckKey = "CheckKey"
const TriggerID = "triggerID"
const RemoteAddr = "remoteAddr"
const (
UnreliableNotification = 1
+8
View File
@@ -148,6 +148,8 @@ func (l *ZapLogger) kvAppend(ctx context.Context, keysAndValues []interface{}) [
opUserID := mcontext.GetOpUserID(ctx)
connID := mcontext.GetConnID(ctx)
triggerID := mcontext.GetTriggerID(ctx)
opUserPlatform := mcontext.GetOpUserPlatform(ctx)
remoteAddr := mcontext.GetRemoteAddr(ctx)
if opUserID != "" {
keysAndValues = append([]interface{}{constant.OpUserID, opUserID}, keysAndValues...)
}
@@ -160,6 +162,12 @@ func (l *ZapLogger) kvAppend(ctx context.Context, keysAndValues []interface{}) [
if triggerID != "" {
keysAndValues = append([]interface{}{constant.TriggerID, triggerID}, keysAndValues...)
}
if opUserPlatform != "" {
keysAndValues = append([]interface{}{constant.OpUserPlatform, opUserPlatform}, keysAndValues...)
}
if remoteAddr != "" {
keysAndValues = append([]interface{}{constant.RemoteAddr, remoteAddr}, keysAndValues...)
}
return keysAndValues
}
+9
View File
@@ -81,6 +81,15 @@ func GetOpUserPlatform(ctx context.Context) string {
}
return ""
}
func GetRemoteAddr(ctx context.Context) string {
if ctx.Value(constant.RemoteAddr) != "" {
s, ok := ctx.Value(constant.RemoteAddr).(string)
if ok {
return s
}
}
return ""
}
func GetMustCtxInfo(ctx context.Context) (operationID, opUserID, platform, connID string, err error) {
operationID, ok := ctx.Value(constant.OperationID).(string)