Skip to content

Commit

Permalink
chore: revise name
Browse files Browse the repository at this point in the history
  • Loading branch information
ppzqh committed Dec 8, 2023
1 parent 056a27f commit 68cfe2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/utils/kitexutil/kitexutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,18 @@ func GetRPCInfo(ctx context.Context) (rpcinfo.RPCInfo, bool) {
return ri, true
}

// GetRealRequest assert the req to be KitexArgs and return the real request if succeeded, otherwise return nil.
// GetRealReqFromKitexArgs assert the req to be KitexArgs and return the real request if succeeded, otherwise return nil.
// This method should be used in the middleware.
func GetRealRequest(req interface{}) interface{} {
func GetRealReqFromKitexArgs(req interface{}) interface{} {
if arg, ok := req.(utils.KitexArgs); ok {
return arg.GetFirstArgument()
}
return nil
}

// GetRealResponse assert the req to be KitexResult and return the real response if succeeded, otherwise return nil.
// GetRealRespFromKitexResult assert the req to be KitexResult and return the real response if succeeded, otherwise return nil.
// This method should be used in the middleware.
func GetRealResponse(resp interface{}) interface{} {
func GetRealRespFromKitexResult(resp interface{}) interface{} {
if res, ok := resp.(utils.KitexResult); ok {
return res.GetResult()
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/utils/kitexutil/kitexutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ func TestGetRealRequest(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetRealRequest(tt.args.req); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetRealRequest() = %v, want %v", got, tt.want)
if got := GetRealReqFromKitexArgs(tt.args.req); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetRealReqFromKitexArgs() = %v, want %v", got, tt.want)
}
})
}
Expand All @@ -306,8 +306,8 @@ func TestGetRealResponse(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := GetRealResponse(tt.args.resp); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetRealResponse() = %v, want %v", got, tt.want)
if got := GetRealRespFromKitexResult(tt.args.resp); !reflect.DeepEqual(got, tt.want) {
t.Errorf("GetRealRespFromKitexResult() = %v, want %v", got, tt.want)
}
})
}
Expand Down

0 comments on commit 68cfe2d

Please sign in to comment.