Skip to content

Commit

Permalink
feat: only recover in sd mode
Browse files Browse the repository at this point in the history
  • Loading branch information
welkeyever committed May 17, 2024
1 parent 49d165b commit 4a32011
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions client/localsession.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package client

import (
"context"

"github.com/cloudwego/hertz/pkg/app/client"
"github.com/cloudwego/hertz/pkg/protocol"
"github.com/cloudwego/localsession/backup"
Expand All @@ -27,6 +28,10 @@ import (
func CtxRecover(hdl backup.BackupHandler) client.Middleware {
return func(next client.Endpoint) client.Endpoint {
return func(ctx context.Context, req *protocol.Request, resp *protocol.Response) (err error) {
// only recover ctx in sd mode
if !req.Options().IsSD() {
return next(ctx, req, resp)
}
ctx = backup.RecoverCtxOnDemands(ctx, hdl)
return next(ctx, req, resp)
}
Expand Down

0 comments on commit 4a32011

Please sign in to comment.