@@ -40,8 +40,7 @@ func NewTokenLockStore(dbs *common2.RWDB, tableNames common.TableNames) (*TokenL
4040}
4141
4242func (db * TokenLockStore ) Cleanup (ctx context.Context , leaseExpiry time.Duration ) error {
43- _ , err := db .logStaleLocks (ctx , leaseExpiry )
44- if err != nil {
43+ if _ , err := db .logStaleLocks (ctx , leaseExpiry ); err != nil {
4544 db .Logger .Warnf ("Could not log stale locks: %v" , err )
4645 }
4746 tokenLocks , tokenRequests := q .Table (db .Table .TokenLocks ), q .Table (db .Table .Requests )
@@ -57,14 +56,14 @@ func (db *TokenLockStore) Cleanup(ctx context.Context, leaseExpiry time.Duration
5756 Build ()
5857
5958 db .Logger .Debug (query )
60- _ , err = db .WriteDB .ExecContext (ctx , query , args ... )
59+ _ , err : = db .WriteDB .ExecContext (ctx , query , args ... )
6160 if err != nil {
6261 db .Logger .Errorf ("query failed: %s" , query )
6362 }
6463 return err
6564}
6665
67- func (db * TokenLockStore ) logStaleLocks (ctx context.Context , leaseExpiry time.Duration ) ([]LockEntry , error ) {
66+ func (db * TokenLockStore ) logStaleLocks (ctx context.Context , leaseExpiry time.Duration ) ([]lockEntry , error ) {
6867 if ! db .Logger .IsEnabledFor (zapcore .InfoLevel ) {
6968 return nil , nil
7069 }
@@ -84,7 +83,7 @@ func (db *TokenLockStore) logStaleLocks(ctx context.Context, leaseExpiry time.Du
8483 return nil , err
8584 }
8685
87- it := common4 .NewIterator (rows , func (entry * LockEntry ) error {
86+ it := common4 .NewIterator (rows , func (entry * lockEntry ) error {
8887 entry .LeaseExpiry = leaseExpiry
8988 return rows .Scan (& entry .ConsumerTxID , & entry .TokenID .TxId , & entry .TokenID .Index , & entry .Status , & entry .CreatedAt , & entry .Now )
9089 })
@@ -97,7 +96,7 @@ func (db *TokenLockStore) logStaleLocks(ctx context.Context, leaseExpiry time.Du
9796 return lockEntries , nil
9897}
9998
100- type LockEntry struct {
99+ type lockEntry struct {
101100 ConsumerTxID string
102101 TokenID token.ID
103102 Status * driver.TxStatus
@@ -106,11 +105,11 @@ type LockEntry struct {
106105 LeaseExpiry time.Duration
107106}
108107
109- func (e LockEntry ) Expired () bool {
108+ func (e lockEntry ) Expired () bool {
110109 return e .CreatedAt .Add (e .LeaseExpiry ).Before (e .Now )
111110}
112111
113- func (e LockEntry ) String () string {
112+ func (e lockEntry ) String () string {
114113 if expired := e .Expired (); e .Status == nil && expired {
115114 return fmt .Sprintf ("Expired lock created at [%v] for token [%s] consumed by [%s]" , e .CreatedAt , e .TokenID , e .ConsumerTxID )
116115 } else if e .Status != nil && * e .Status == driver .Deleted && ! expired {
0 commit comments