|
|
|
@ -13,6 +13,7 @@ import ( |
|
|
|
"github.com/dtm-labs/dtm/client/dtmcli" |
|
|
|
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp" |
|
|
|
"github.com/dtm-labs/dtm/client/dtmgrpc/dtmgimp" |
|
|
|
grpc "google.golang.org/grpc" |
|
|
|
"google.golang.org/protobuf/proto" |
|
|
|
) |
|
|
|
|
|
|
|
@ -62,7 +63,7 @@ func (s *MsgGrpc) DoAndSubmitDB(queryPrepared string, db *sql.DB, busiCall dtmcl |
|
|
|
// the error returned by busiCall will be returned
|
|
|
|
// if busiCall return ErrFailure, then abort is called directly
|
|
|
|
// if busiCall return not nil error other than ErrFailure, then DoAndSubmit will call queryPrepared to get the result
|
|
|
|
func (s *MsgGrpc) DoAndSubmit(queryPrepared string, busiCall func(bb *dtmcli.BranchBarrier) error) error { |
|
|
|
func (s *MsgGrpc) DoAndSubmit(queryPrepared string, busiCall func(bb *dtmcli.BranchBarrier) error, opts ...grpc.CallOption) error { |
|
|
|
bb, err := dtmcli.BarrierFrom(s.TransType, s.Gid, dtmimp.MsgDoBranch0, dtmimp.MsgDoOp) // a special barrier for msg QueryPrepared
|
|
|
|
if err == nil { |
|
|
|
err = s.Prepare(queryPrepared) |
|
|
|
@ -70,7 +71,7 @@ func (s *MsgGrpc) DoAndSubmit(queryPrepared string, busiCall func(bb *dtmcli.Bra |
|
|
|
if err == nil { |
|
|
|
errb := busiCall(bb) |
|
|
|
if errb != nil && !errors.Is(errb, dtmcli.ErrFailure) { |
|
|
|
err = dtmgimp.InvokeBranch(&s.TransBase, true, nil, queryPrepared, &[]byte{}, bb.BranchID, bb.Op) |
|
|
|
err = dtmgimp.InvokeBranch(&s.TransBase, true, nil, queryPrepared, &[]byte{}, bb.BranchID, bb.Op, opts...) |
|
|
|
err = GrpcError2DtmError(err) |
|
|
|
} |
|
|
|
if errors.Is(errb, dtmcli.ErrFailure) || errors.Is(err, dtmcli.ErrFailure) { |
|
|
|
|