77 "time"
88
99 /* TODO: fix the cyclic dependencies */
10- "github.com/PythonHacker24/linux-acl-management-backend/internal/transprocessor"
10+
11+ "github.com/PythonHacker24/linux-acl-management-backend/internal/types"
1112)
1213
1314/* we make use of Redis hashes for this application */
@@ -41,15 +42,15 @@ func (m *Manager) saveSession(username string) error {
4142 if err := m .redis .HSet (ctx , key , sessionSerialized ).Err (); err != nil {
4243 return fmt .Errorf ("failed to save session to Redis: %w" , err )
4344 }
44-
45+
4546 return nil
4647}
4748
4849/* update expiry time in session */
4950func (m * Manager ) updateSessionExpiry (username string ) error {
50-
51- /*
52- function expects that new expiry time is already set in the session
51+
52+ /*
53+ function expects that new expiry time is already set in the session
5354 */
5455
5556 ctx := context .Background ()
@@ -78,7 +79,7 @@ func (m *Manager) updateSessionExpiry(username string) error {
7879 err := m .redis .HSet (ctx , key , "expiry" , formattedExpiry ).Err ()
7980 if err != nil {
8081 return fmt .Errorf ("failed to update session expiry in Redis: %w" , err )
81- }
82+ }
8283
8384 return nil
8485}
@@ -87,7 +88,7 @@ func (m *Manager) updateSessionExpiry(username string) error {
8788
8889/* update status of the session - update and set expired operations will be done with this */
8990func (m * Manager ) updateSessionStatus (username string , status Status ) error {
90-
91+
9192 ctx := context .Background ()
9293
9394 /* thread safety for the manager */
@@ -117,7 +118,7 @@ func (m *Manager) updateSessionStatus(username string, status Status) error {
117118}
118119
119120/* save transaction results to redis */
120- func (m * Manager ) saveTransactionResults (username string , txResult transprocessor .Transaction ) error {
121+ func (m * Manager ) saveTransactionResults (username string , txResult types .Transaction ) error {
121122
122123 ctx := context .Background ()
123124
@@ -151,9 +152,9 @@ func (m *Manager) saveTransactionResults(username string, txResult transprocesso
151152 return m .redis .RPush (ctx , key , resultBytes ).Err ()
152153}
153154
154- func (m * Manager ) getTransactionResults (username string , limit int ) ([]TransactionResult , error ) {
155+ func (m * Manager ) getTransactionResults (username string , limit int ) ([]types. TransactionResult , error ) {
155156 ctx := context .Background ()
156-
157+
157158 /* thread safety for the manager */
158159 m .mutex .Lock ()
159160 defer m .mutex .Unlock ()
@@ -173,17 +174,17 @@ func (m *Manager) getTransactionResults(username string, limit int) ([]Transacti
173174
174175 /* create a key for Redis operation */
175176 key := fmt .Sprintf ("session:%s:txresults" , sessionID )
176-
177+
177178 /* returns transactions in chronological order */
178179 values , err := m .redis .LRange (ctx , key , int64 (- limit ), - 1 ).Result ()
179180 if err != nil {
180181 return nil , fmt .Errorf ("failed to get transaction results: %w" , err )
181182 }
182183
183184 /* converts each JSON string back into a TransactionResult */
184- results := make ([]TransactionResult , 0 , len (values ))
185+ results := make ([]types. TransactionResult , 0 , len (values ))
185186 for _ , val := range values {
186- var result TransactionResult
187+ var result types. TransactionResult
187188 if err := json .Unmarshal ([]byte (val ), & result ); err != nil {
188189 /* skip malformed results */
189190 continue
0 commit comments