2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
30 type TransactionXappKey struct {
32 Xid string // xapp xid in req
35 func (key *TransactionXappKey) String() string {
36 return key.RmrEndpoint.String() + "/" + key.Xid
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
42 type Transaction struct {
44 tracker *Tracker // tracker instance
46 RmrEndpoint RmrEndpoint
48 Xid string // xapp xid in req
49 OrigParams *RMRParams // request orginal params
51 ForwardRespToXapp bool
54 func (t *Transaction) String() string {
56 defer t.mutex.Unlock()
57 var subId string = "?"
59 subId = strconv.FormatUint(uint64(t.Subs.Seq), 10)
61 return subId + "/" + t.RmrEndpoint.String() + "/" + t.Xid
64 func (t *Transaction) GetXid() string {
66 defer t.mutex.Unlock()
70 func (t *Transaction) GetMtype() int {
72 defer t.mutex.Unlock()
76 func (t *Transaction) GetSrc() string {
78 defer t.mutex.Unlock()
79 return t.RmrEndpoint.String()
82 func (t *Transaction) CheckResponseReceived() bool {
84 defer t.mutex.Unlock()
85 if t.RespReceived == false {
92 func (t *Transaction) RetryTransaction() {
94 defer t.mutex.Unlock()
95 t.RespReceived = false
98 func (t *Transaction) Release() {
100 defer t.mutex.Unlock()
102 t.Subs.UnSetTransaction(t)
104 if t.tracker != nil {
105 xappkey := TransactionXappKey{t.RmrEndpoint, t.Xid}
106 t.tracker.UnTrackTransaction(xappkey)