I'm gonna have to rework some of the error types.
Given the following output():
fn output(request: Request, decision: Decision) -> Result[Response, Report] {
let response = Response.empty();
Ok(response)
}
iocaine 4 benchmarks the http::Request + http::Response variant at ~77ns, while the dummy variant is ~17ns.
I'll go and benchmark iocaine3's output() too, out of curiosity.
After applying a hacky workaround to unblock myself:
❯ cargo run -q -- self-test -v 2>/dev/null
1..11
ok 1 dep.nam_shub_of_enki.pkg.checks.ai_robots_txt.ai_robots_txt
ok 2 dep.nam_shub_of_enki.pkg.checks.faked_browser.faked_browser
ok 3 dep.nam_shub_of_enki.pkg.checks.poisoned_urls.poisoned_url
ok 4 dep.nam_shub_of_enki.pkg.tests.decide_curl_ok
ok 5 dep.nam_shub_of_enki.pkg.tests.output_default_ok
ok 6 pkg.unit_tests.ipprefix
ok 7 pkg.unit_tests.maxmind_default
ok 8 pkg.unit_tests.regex_default
ok 9 pkg.unit_tests.report
ok 10 pkg.unit_tests.secchua
ok 11 pkg.unit_tests.secchua_default
Now that looks nice! I can have the tests near the check, right there and then and all that. This will make it easier to tangle these out, too.
http-server default {
bind-to "127.0.0.1:42069"
script {
module "nam_shub_of_enki" path="nam-shub-of-enki"
// None of the configuration is effective yet!
//
// This is *only* here to feel out how the configuration might look in
// the future.
configuration {
set ai.robots.txt::botlist-file "assets/ai.robots.txt-botlist.txt"
append-to ai.robots.txt::excluded-bots "Dot" "nbot" "Operator" "Spider"
append-to poisoned-urls::identifiers "abrakadabra"
}
}
}
I think I like this, though I'm a bit torn on what kind syntax I want to support for lists: do I just... list all the items, like above? Or do I make the items children, like below:
append-to ai.robots.txt::excluded-bots {
- Dot
- nbot
- Operator
- Spider
}
...or do I support both, because depending on the number of items, or the context, either one can make more sense than the other.
ai.robots.txt::excluded-bots {
- Dot
- nbot
}
ai.robots.txt::excluded-bots + {
- Operator
- GPTBot
}
ai.robots.txt::excluded-bots - GPTBot
+ and append would add items, - and remove would remove them, and no-argument or set would set the list to that particular value. Values can either be children in the { - item } format, or arguments for the node itself, whichever feels more comfy when writing.
I don't currently feel like working on configuration, that... looks like it will have some sharp edges.
So tomorrow, I'll do the SPOA server, and see if I can get the generators up and running.
Will have to ponder about templating, though.
I don't miss much from iocaine 2.x, it was... not very nice, 3.x was a big step up (and I hope 4.x will be an even larger). But there's one particular feature iocaine 2.x had that 3.x does not, and I'm not sure how to reintroduce it to 4.x: the template being able to call garbage generating functions.
That meant I didn't have to pre-generate the garbage, and present it in a particular shape, to be spliced into the template, but the template could fully drive how it wanted to look.
I want that back. It was nice.
The major problem is the RNG. That's... hard to make available to the template when the engine does not support having a per-render context I could mutate, or a per-function mutable state.
minijinja had mutable state functions could use to, well, keep state. There's no such thing in upon.
Unfortunately, the templating libs are... eh. minijinja is slop, askama and tinytemplate are compile-time.
Now Tera... It looks like I can impl Function for a type, and that type can hold an internally mutable thing, which means I might be able to wrap rng, which in turn would let me make the template call garbage generators.
There's a problem, though, which I think both upon and tera share: this internal mutability is bound to the function, which lives for the entire duration of the engine.
And that is a Problem, because I want per-render context. That lets me avoid locks, that makes it possible to have stable RNG, so that if the same page is reloaded, the RNG will generate the exact same numbers.
I need render-bound context.
Mm, no. No, can't do that. Both upon and Tera want the function results to convert to upon/Tera values, and that makes my lightbulb idea impossible.
The idea was to provide an init_rng() function that returned a function I could then call as rand(), and that function would then be template-bound, and could have as much internal mutability as it wants.
But alas, can't do that.
Bwaahahaha.