Browse Source

TransBase setup func

pull/368/head
junzhou.guo 3 years ago
parent
commit
e7bcf80c95
  1. 10
      client/dtmgrpc/msg.go
  2. 15
      client/dtmgrpc/options.go

10
client/dtmgrpc/msg.go

@ -24,8 +24,14 @@ type MsgGrpc struct {
}
// NewMsgGrpc create new msg
func NewMsgGrpc(server string, gid string) *MsgGrpc {
return &MsgGrpc{Msg: *dtmcli.NewMsg(server, gid)}
func NewMsgGrpc(server string, gid string, opts ...TransBaseOption) *MsgGrpc {
mg := &MsgGrpc{Msg: *dtmcli.NewMsg(server, gid)}
for _, opt := range opts {
opt(&mg.TransBase)
}
return mg
}
// Add add a new step

15
client/dtmgrpc/options.go

@ -0,0 +1,15 @@
package dtmgrpc
import (
"github.com/dtm-labs/dtm/client/dtmcli/dtmimp"
)
// TransBaseOption setup func for TransBase
type TransBaseOption func(tb *dtmimp.TransBase)
// WithBranchHeaders setup TransBase.BranchHeaders
func WithBranchHeaders(headers map[string]string) TransBaseOption {
return func(tb *dtmimp.TransBase) {
tb.BranchHeaders = headers
}
}
Loading…
Cancel
Save