Browse Source

Merge pull request #392 from ostafen/fix/workflow-interceptor

Call invoker if Workflow is nil
pull/393/head v1.16.10
yedf2 3 years ago
committed by GitHub
parent
commit
2cd5f5ddc4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      client/workflow/workflow.go
  2. 19
      test/workflow_interceptor_test.go

2
client/workflow/workflow.go

@ -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 {

19
test/workflow_interceptor_test.go

@ -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)
}
Loading…
Cancel
Save