Skip to content

Commit

Permalink
Merge pull request #392 from ostafen/fix/workflow-interceptor
Browse files Browse the repository at this point in the history
Call invoker if Workflow is nil
  • Loading branch information
yedf2 authored Jan 26, 2023
2 parents be759b9 + 5b2b4d5 commit 2cd5f5d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/workflow/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func Interceptor(ctx context.Context, method string, req, reply interface{}, cc
logger.Debugf("grpc client calling: %s%s %v", cc.Target(), method, dtmimp.MustMarshalString(req))
wf, _ := ctx.Value(wfMeta{}).(*Workflow)
if wf == nil {
return nil
return invoker(ctx, method, req, reply, cc, opts...)
}

origin := func() error {
Expand Down
19 changes: 19 additions & 0 deletions test/workflow_interceptor_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package test

import (
"context"
"testing"

"github.com/dtm-labs/dtm/client/workflow"
"github.com/stretchr/testify/assert"
"google.golang.org/grpc"
)

func TestWorkflowInterceptorOutsideSaga(t *testing.T) {
called := false
workflow.Interceptor(context.TODO(), "method", nil, nil, &grpc.ClientConn{}, func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, opts ...grpc.CallOption) error {
called = true
return nil
})
assert.True(t, called)
}

0 comments on commit 2cd5f5d

Please sign in to comment.