🔥A cross-language distributed transaction manager. Support xa, tcc, saga, transactional messages. 跨语言分布式事务管理器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
875 B

package dtmcli
// Msg reliable msg type
type Msg struct {
TransBase
Steps []MsgStep `json:"steps"`
QueryPrepared string `json:"query_prepared"`
}
// MsgStep struct of one step msg
type MsgStep struct {
Action string `json:"action"`
Data string `json:"data"`
}
// NewMsg create new msg
func NewMsg(server string, gid string) *Msg {
return &Msg{TransBase: *NewTransBase(gid, "msg", server, "")}
}
// Add add a new step
func (s *Msg) Add(action string, postData interface{}) *Msg {
s.Steps = append(s.Steps, MsgStep{
Action: action,
Data: MustMarshalString(postData),
})
return s
}
// Prepare prepare the msg
func (s *Msg) Prepare(queryPrepared string) error {
s.QueryPrepared = OrString(queryPrepared, s.QueryPrepared)
return s.callDtm(s, "prepare")
}
// Submit submit the msg
func (s *Msg) Submit() error {
return s.callDtm(s, "submit")
}