mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
Merge 56fd4ed639b30036cea182cb7158c517770f44d1 into 96196ab8bc05f31b09dac2403f9d5de3bc05f31b
This commit is contained in:
commit
3c3a95a03a
@ -23,6 +23,8 @@ suite "Postgres driver":
|
||||
|
||||
driver = PostgresDriver(driverRes.get())
|
||||
|
||||
(await driver.waitForPartition()).expect("Test has no DB partition")
|
||||
|
||||
asyncTeardown:
|
||||
let resetRes = await driver.reset()
|
||||
if resetRes.isErr():
|
||||
|
||||
@ -38,6 +38,8 @@ suite "Postgres driver - queries":
|
||||
|
||||
driver = PostgresDriver(driverRes.get())
|
||||
|
||||
(await driver.waitForPartition()).expect("Test has no DB partition")
|
||||
|
||||
asyncTeardown:
|
||||
let resetRes = await driver.reset()
|
||||
|
||||
|
||||
@ -1422,6 +1422,21 @@ proc removeOldestPartition(
|
||||
proc containsAnyPartition*(self: PostgresDriver): bool =
|
||||
return not self.partitionMngr.isEmpty()
|
||||
|
||||
proc waitForPartition*(
|
||||
self: PostgresDriver, timeout = chronos.seconds(5)
|
||||
): Future[ArchiveDriverResult[void]] {.async.} =
|
||||
let pollInterval = chronos.milliseconds(100)
|
||||
var elapsed = chronos.milliseconds(0)
|
||||
|
||||
while elapsed < timeout:
|
||||
if self.containsAnyPartition():
|
||||
return ok()
|
||||
|
||||
await sleepAsync(pollInterval)
|
||||
elapsed += pollInterval
|
||||
|
||||
return err("PostgresDriver.waitForPartition() timed out after " & $timeout)
|
||||
|
||||
method decreaseDatabaseSize*(
|
||||
driver: PostgresDriver, targetSizeInBytes: int64, forceRemoval: bool = false
|
||||
): Future[ArchiveDriverResult[void]] {.async.} =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user