2024-03-15 23:08:47 +00:00
|
|
|
import chronicles, chronos
|
2024-03-01 11:05:27 +00:00
|
|
|
import
|
2024-07-05 22:03:38 +00:00
|
|
|
waku/[
|
|
|
|
waku_archive,
|
|
|
|
waku_archive/driver as driver_module,
|
|
|
|
waku_archive/driver/builder,
|
|
|
|
waku_archive/driver/postgres_driver,
|
|
|
|
]
|
2024-03-01 11:05:27 +00:00
|
|
|
|
|
|
|
const storeMessageDbUrl = "postgres://postgres:test123@localhost:5432/postgres"
|
|
|
|
|
|
|
|
proc newTestPostgresDriver*(): Future[Result[ArchiveDriver, string]] {.async.} =
|
|
|
|
proc onErr(errMsg: string) {.gcsafe, closure.} =
|
|
|
|
error "error creating ArchiveDriver", error = errMsg
|
|
|
|
quit(QuitFailure)
|
|
|
|
|
|
|
|
let
|
|
|
|
vacuum = false
|
|
|
|
migrate = true
|
|
|
|
maxNumConn = 50
|
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
let driverRes =
|
|
|
|
await ArchiveDriver.new(storeMessageDbUrl, vacuum, migrate, maxNumConn, onErr)
|
2024-03-01 11:05:27 +00:00
|
|
|
if driverRes.isErr():
|
|
|
|
onErr("could not create archive driver: " & driverRes.error)
|
|
|
|
|
|
|
|
return ok(driverRes.get())
|