Skip to content

Commit 656e3a3

Browse files
Added complete archival logic for pending transactions
1 parent 9e031f7 commit 656e3a3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

internal/session/interact.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,14 @@ func (m *Manager) ExpireSession(username string) {
8888
if !ok {
8989
continue
9090
}
91-
txResult.Status = string(StatusPending)
91+
txResult.Status = types.StatusPending
9292
/* TODO: Push this all into PostgreSQL */
93+
txnPQ, err := ConvertTransactiontoStoreParams(txResult)
94+
if err != nil {
95+
/* error is conversion, continue the loop in good faith */
96+
/* need to handle these errors later */
97+
}
98+
if err == nil { m.archivalPQ.CreateTransactionPQ(context.Background(), txnPQ) }
9399
}
94100
} else {
95101
/* no empty transactions; mark the session as expired */
@@ -104,11 +110,12 @@ func (m *Manager) ExpireSession(username string) {
104110
/* convert all session parameters to PostgreSQL compatible parameters */
105111
archive, err := ConvertSessionToStoreParams(session)
106112
if err != nil {
107-
return
113+
/* session conversion failed, leave it in good faith */
114+
/* handle err later */
108115
}
109116

110117
/* store session to the archive */
111-
m.archivalPQ.StoreSessionPQ(context.Background(), *archive)
118+
if err == nil { m.archivalPQ.StoreSessionPQ(context.Background(), *archive) }
112119

113120
/* remove session from sessionsMap */
114121
delete(m.sessionsMap, username)

0 commit comments

Comments
 (0)