+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type TransactionXappKey struct {
+ RmrEndpoint
+ Xid string // xapp xid in req
+}
+
+func (key *TransactionXappKey) String() string {
+ return key.RmrEndpoint.String() + "/" + key.Xid
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type Transaction struct {
+ tracker *Tracker // tracker instance
+ Subs *Subscription
+ RmrEndpoint RmrEndpoint
+ Xid string // xapp xid in req
+ OrigParams *xapp.RMRParams // request orginal params
+ RespReceived bool
+ ForwardRespToXapp bool
+ mutex sync.Mutex
+}
+
+func (t *Transaction) String() string {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ var subId string = "?"
+ if t.Subs != nil {
+ subId = strconv.FormatUint(uint64(t.Subs.Seq), 10)
+ }
+ return subId + "/" + t.RmrEndpoint.String() + "/" + t.Xid
+}
+
+func (t *Transaction) CheckResponseReceived() bool {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ if t.RespReceived == false {
+ t.RespReceived = true
+ return false
+ }
+ return true
+}
+
+func (t *Transaction) RetryTransaction() {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ t.RespReceived = false
+}
+
+func (t *Transaction) Release() {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ if t.Subs != nil {
+ t.Subs.UnSetTransaction(t)
+ }
+ if t.tracker != nil {
+ xappkey := TransactionXappKey{t.RmrEndpoint, t.Xid}
+ t.tracker.UnTrackTransaction(xappkey)
+ }
+ t.Subs = nil
+ t.tracker = nil
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------