@@ -93,6 +93,9 @@ type Options struct {
9393 // Default == GrpcError2DtmError: Code Aborted => ErrFailure; Code FailedPrecondition => ErrOngoing
9494 GRPCError2DtmError func (error ) error
9595
96+ // Default == KitexError2DtmError: Code Aborted | Code Internal => ErrFailure; Code FailedPrecondition => ErrOngoing
97+ KITEXError2DtmError func (error ) error
98+
9699 // This Option specify whether a branch returning ErrFailure should be compensated on rollback.
97100 // for most idempotent branches, no compensation is needed.
98101 // But for a timeout request, the caller cannot know where the request is successful, so the compensation should be called
@@ -264,7 +267,7 @@ func Interceptor(ctx context.Context, method string, req, reply interface{}, cc
264267 return wf .stepResultToGrpc (sr , reply )
265268}
266269
267- // KitexInterceptor is the middleware for workflow to capture grpc call result
270+ // KitexInterceptor is the middleware for workflow to capture kitex grpc call result
268271func KitexInterceptor (next endpoint.Endpoint ) endpoint.Endpoint {
269272 return func (ctx context.Context , req , resp interface {}) (err error ) {
270273 ri := rpcinfo .GetRPCInfo (ctx )
@@ -278,7 +281,7 @@ func KitexInterceptor(next endpoint.Endpoint) endpoint.Endpoint {
278281 origin := func () error {
279282 ctx1 := dtmgimp .TransInfo2Ctx (ctx , wf .Gid , wf .TransType , wf .currentBranch , wf .currentOp , wf .Dtm )
280283 err := next (ctx1 , req , resp )
281- res := fmt .Sprintf ("grpc client called: %s%s %s result: %s err: %v" ,
284+ res := fmt .Sprintf ("Kitex client called: %s%s %s result: %s err: %v" ,
282285 ri .To ().ServiceName (), ri .To ().Method (), dtmimp .MustMarshalString (req ), dtmimp .MustMarshalString (resp ), err )
283286 if err != nil {
284287 logger .Errorf ("%s" , res )
@@ -292,9 +295,9 @@ func KitexInterceptor(next endpoint.Endpoint) endpoint.Endpoint {
292295 }
293296 sr := wf .recordedDo (func (bb * dtmcli.BranchBarrier ) * stepResult {
294297 err := origin ()
295- return wf .stepResultFromGrpc (resp , err )
298+ return wf .stepResultFromKitex (resp , err )
296299 })
297- return wf .stepResultToGrpc (sr , resp )
300+ return wf .stepResultToKitex (sr , resp )
298301 }
299302
300303}
0 commit comments