2025-02-05 15:21:11 +01:00
|
|
|
import std/os
|
2025-02-04 16:25:38 +01:00
|
|
|
import pkg/chronicles
|
|
|
|
|
import pkg/chronos
|
2025-02-05 15:21:11 +01:00
|
|
|
import pkg/questionable
|
|
|
|
|
import pkg/questionable/results
|
2025-02-04 16:25:38 +01:00
|
|
|
|
2025-02-05 15:21:11 +01:00
|
|
|
import pkg/datastore
|
|
|
|
|
import pkg/datastore/typedds
|
2025-02-05 14:05:18 +01:00
|
|
|
import pkg/metrics
|
|
|
|
|
|
2025-02-05 15:21:11 +01:00
|
|
|
import ./config
|
2025-02-05 14:05:18 +01:00
|
|
|
import ./list
|
|
|
|
|
|
2025-02-04 16:25:38 +01:00
|
|
|
logScope:
|
|
|
|
|
topics = "main"
|
|
|
|
|
|
2025-02-05 14:05:18 +01:00
|
|
|
declareGauge(example, "testing")
|
|
|
|
|
|
2025-02-05 15:21:11 +01:00
|
|
|
proc startApplication*(config: CrawlerConfig): Future[?!void] {.async.} =
|
|
|
|
|
without exampleStore =? LevelDbDatastore.new(config.dataDir / "example"):
|
|
|
|
|
error "Failed to create datastore"
|
|
|
|
|
return failure("Failed to create datastore")
|
|
|
|
|
|
|
|
|
|
let typedDs = TypedDatastore.init(exampleStore)
|
|
|
|
|
|
2025-02-05 14:05:18 +01:00
|
|
|
proc onExampleMetric(value: int64) =
|
|
|
|
|
example.set(value)
|
2025-02-05 15:21:11 +01:00
|
|
|
|
|
|
|
|
var exampleList = List.new("example", typedDs, onExampleMetric)
|
|
|
|
|
if err =? (await exampleList.load()).errorOption:
|
|
|
|
|
return failure(err)
|
2025-02-05 14:05:18 +01:00
|
|
|
|
2025-02-04 16:25:38 +01:00
|
|
|
proc aaa() {.async.} =
|
|
|
|
|
while true:
|
2025-02-05 15:21:11 +01:00
|
|
|
trace "a"
|
2025-02-04 16:25:38 +01:00
|
|
|
await sleepAsync(1000)
|
2025-02-05 15:21:11 +01:00
|
|
|
discard await exampleList.add(Entry(
|
|
|
|
|
value: "str!"
|
|
|
|
|
))
|
2025-02-05 14:05:18 +01:00
|
|
|
|
2025-02-04 16:25:38 +01:00
|
|
|
|
|
|
|
|
asyncSpawn aaa()
|
2025-02-05 11:06:18 +01:00
|
|
|
|
2025-02-04 16:25:38 +01:00
|
|
|
await sleepAsync(1000)
|
|
|
|
|
|
|
|
|
|
notice "b"
|
2025-02-05 15:21:11 +01:00
|
|
|
return success()
|