-/*
-Deletes the transaction table entry for the given request and returns the deleted xapp's address and port for reference.
-Returns error in case the transaction cannot be found.
-*/
-func (t *Tracker) complete_transaction(subID uint16, act Action) (*string, *uint16, error){
- key := Transaction_key{subID, act}
- if xact, ok := t.transaction_table[key]; ok {
- delete(t.transaction_table, key)
- return &(xact.Xapp_instance_address), &(xact.Xapp_port), nil
+func (t *Tracker) Track(trans *TransactionXapp) error {
+
+ if trans.GetEndpoint() == nil {
+ err := fmt.Errorf("Tracker: No valid endpoint given in %s", trans.String())
+ return err
+ }
+
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+
+ theKey := *trans.XappKey
+
+ if othtrans, ok := t.transactionXappTable[theKey]; ok {
+ err := fmt.Errorf("Tracker: %s is ongoing, not tracking %s", othtrans, trans)
+ return err
+ }
+
+ trans.tracker = t
+ t.transactionXappTable[theKey] = trans
+ xapp.Logger.Debug("Tracker: Append %s", trans.String())
+ //xapp.Logger.Debug("Tracker: transtable=%v", t.transactionXappTable)
+ return nil
+}
+
+func (t *Tracker) UnTrackTransaction(xappKey TransactionXappKey) (*TransactionXapp, error) {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ if trans, ok2 := t.transactionXappTable[xappKey]; ok2 {
+ xapp.Logger.Debug("Tracker: Remove %s", trans.String())
+ delete(t.transactionXappTable, xappKey)
+ //xapp.Logger.Debug("Tracker: transtable=%v", t.transactionXappTable)
+ return trans, nil