Improve session cleanup (#18123)
- We move logging statements to the upper layer. Store functions are low-level methods and should return error upwards rather than logging. - Used IN instead of any (array ()) which is equivalent. - Made the delay to be of type time.Duration and un-exported it. - Unexported the batch size constant. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2711262729
Коммит
d1b164ab1f
@@ -38,8 +38,17 @@ func (_m *SessionStore) AnalyticsSessionCount() (int64, error) {
|
||||
}
|
||||
|
||||
// Cleanup provides a mock function with given fields: expiryTime, batchSize
|
||||
func (_m *SessionStore) Cleanup(expiryTime int64, batchSize int64) {
|
||||
_m.Called(expiryTime, batchSize)
|
||||
func (_m *SessionStore) Cleanup(expiryTime int64, batchSize int64) error {
|
||||
ret := _m.Called(expiryTime, batchSize)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(int64, int64) error); ok {
|
||||
r0 = rf(expiryTime, batchSize)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// Get provides a mock function with given fields: ctx, sessionIDOrToken
|
||||
|
||||
@@ -303,7 +303,8 @@ func testSessionCleanup(t *testing.T, ss store.Store) {
|
||||
s4, err = ss.Session().Save(s4)
|
||||
require.NoError(t, err)
|
||||
|
||||
ss.Session().Cleanup(now, 1)
|
||||
err = ss.Session().Cleanup(now, 1)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ss.Session().Get(context.Background(), s1.Id)
|
||||
assert.NoError(t, err)
|
||||
|
||||
Ссылка в новой задаче
Block a user