Initial Dever 0.0.1

This commit is contained in:
Codex committed 2026-11-03 03:32:07 +00:00
commit 81233d098c
1479 files changed
+163782

No files matched your search

+144
View File
@@ -0,0 +1,144 @@
type Identity {
id: Text
user_id: model.id?
tenant_id: model.id?
}
verify(claims: dever.auth.Claims) (identity: Identity) {
identity = Identity {
id = claims.subject
user_id = null
tenant_id = null
}
}
ready() () {
blocking(bench.ready(0))
}
populateOne(value: Int) () {
created = model.create({
value = value
label = "fixture"
})
}
populate() () {
each(populateOne, config.ormRows())
}
crudOnce(value: Int) () {
begin = dever.time.monotonicNanos()
created = model.create({
value = value
label = "created"
})
changed = model.update(created.id, { label = "updated" })
removed = model.delete(created.id)
end = dever.time.monotonicNanos()
blocking(bench.report(begin, end, "crud", 1, changed + removed))
}
listOnce(value: Int) () {
begin = dever.time.monotonicNanos()
page = model.list({
order = id.asc
page = 1
size = 32
})
end = dever.time.monotonicNanos()
blocking(bench.report(begin, end, "list", 1, page.total + length(page.items)))
}
cursorOnce(value: Int) () {
begin = dever.time.monotonicNanos()
page = model.cursor({
order = id.asc
size = 32
})
end = dever.time.monotonicNanos()
blocking(bench.report(begin, end, "cursor", 1, length(page.items)))
}
countItem(value: model.Item, total: Int) (next: Int) {
next = total + 1
}
streamOnce(value: Int) () {
begin = dever.time.monotonicNanos()
rows = model.stream({
order = id.asc
size = 16
})
total = reduce(countItem, rows, 0)
end = dever.time.monotonicNanos()
blocking(bench.report(begin, end, "stream", 1, total))
}
poolOnce(value: Int) () {
begin = dever.time.monotonicNanos()
total = model.count()
end = dever.time.monotonicNanos()
blocking(bench.report(begin, end, "pool", 1, total))
}
transaction fillCancelledTransaction() () {
created = model.create({
value = 1
label = "cancelled"
})
delayed = model.delay(config.ormCancelWork())
}
ormIdle() (result: Bool) {
total = model.count()
blocking(bench.ready(total))
bench.pause(config.lifetime())
result = true
}
ormCrud() (result: Bool) {
ready()
each(crudOnce, config.ormInput())
result = true
}
ormList() (result: Bool) {
populate()
ready()
each(listOnce, config.ormInput())
result = true
}
ormCursor() (result: Bool) {
populate()
ready()
each(cursorOnce, config.ormInput())
result = true
}
ormStream() (result: Bool) {
ready()
each(streamOnce, config.ormInput())
result = true
}
ormPool() (result: Bool) {
ready()
parallelEach(poolOnce, config.ormInput(), config.ormConcurrency())
result = true
}
ormSeed() (result: Bool) {
populate()
result = true
}
count() (total: Int) {
total = model.count()
}
cancel() (result: Bool) {
fillCancelledTransaction()
result = true
}
@@ -0,0 +1,9 @@
public get count = app.count
public post cancel = app.cancel
cmd idle = app.ormIdle
cmd crud = app.ormCrud
cmd list = app.ormList
cmd cursor = app.ormCursor
cmd stream = app.ormStream
cmd pool = app.ormPool
cmd seed = app.ormSeed
@@ -0,0 +1,13 @@
type DelayResult {
total: Int
}
global type Item {
value: Int index
label: Text(1, 32)
}
sql delay(work: Int) (result: DelayResult) {
sqlite = "WITH RECURSIVE counter(value) AS (SELECT 1 UNION ALL SELECT value + 1 FROM counter WHERE value < ?1) SELECT SUM(value) AS total FROM counter"
postgres = "SELECT SUM(value)::bigint AS total FROM generate_series(1::bigint, $1::bigint) AS value"
}