Hi All, Im porting a lib that consumes pedestal 0.6.x to 0.7.x and I am getting stymied by error-dispatch
See the release notes for 0.7.0, this one macro was moved to its own library.
What I am seeing is that the macro seems to not be in the 0.7.0, but I do see it in the current source code. I was thinking it maybe moved to its own lib, but maven doesnt seem to have a released artifact for it
https://mvnrepository.com/artifact/io.pedestal/pedestal.error
guidance appreciated
nm…i think maven central is just stale w.r.t. 0.7.0….none of the other 0.7.0 artifacts show up there either but I can in fact pull pedestal.error down
The contention that routes are “just data” is all too tenuous. For example, I want to build a single routing table with routes that have a mix of servers, ports, and other options (this makes sense when testing the functionality of a router). If I call table/table-routes multiple times and concatenate the results, I end up with something that looks like a routing table, but some of the invariants imposed by route/expand-routes (i.e., that route names are unique) are no longer invariant. The result looks like a routing table (its a seq of expanded route entries) BUT route/expand-routes doesn’t know what to make of it. I’m thinking about how to clean up this mess so that it’s possible to combine these things reasonably. It was more possible to do this using terse routes (the ones where you build up a tree) BUT that still wasn’t set up to allow multiple routes to be combined together. I strongly feel that table routes are the way to go. I also think table/table-routes could be improved to allow you to intersperse option maps with blocks of routing vectors. This might need to have a different name, for compatibility reasons. I wonder how many people out there have built their own specification format or router implementation? This is something the documentation talks about leaving open, but I don’t know how many people take advantage of it. Feedback welcome; I’m struggling with how to make improvements without breaking backwards compatibility.
For me the biggest weakness with pedestal routing is how it handles path parameters. Both in terms of expressiveness (1), but also complexity (2). 1. This is discussed here: https://tonsky.me/blog/simple-router/ For 2) the guide says this: > The map tree router is by far the fastest router in Pedestal. Part of how it gets that speed, though, is by forbidding the use of dynamic path segments like wildcards and path parameters. > If your routes include any of them, then even if you request the map tree router, Pedestal will fall back to using the (still pretty fast) prefix tree router. That seems odd to me, because it sounds like an unnecessary performance cliff. If none of my first path segments are dynamic, shouldn't I benefit from the map speed for dealing with that part of the routing? I would think only matching the dynamic parts of the routing tree would need to use a slower alternative.
That's a good point, and that would be a terrific optimization for the new router (which I call sawtooth, because that's the name that popped into my head).
Sawtooth works by subdividing the routes by each route's port, host, scheme, and method; after that it is routing on the routes' :path. It's essentially breaking the routing table into many little shards, and some of those shards (or subselections of those shards) may be free of wildcards, and could instead be based on a map lookup.
Like a lot of my efforts, the point of sawtooth is to move as much of the logic into a one-time compile phase, to minimize work done at runtime.
That sounds awesome
prefix-tree does some of that, but at the end, it has a bucket of possible routes and has to do some ugly work to find the "best match".
The code is in the hls/842-conflicting-routes branch.
Reading Tonsky's notes ... once I have Sawtooth working and it's basic value proven, then we can figure out how to, for example, allow "/user/create" to match in preference to "/user/:id" if desired.
Enthusiastic about composable routing tables. But not about /user/create shadowing /user/*. Of course I need not design routes that overlap... But in my generosity and selflessness, I think only of the convenience of others others when I gripe and fulminate that this is the sort of thing that people should joyfully program in their own apps and then not blame the framework when Charlie Reate asks why his user account doesn't work.
Yay, found the bug I introduced into prefix-tree router, now I can start comparing perfix-tree and sawtooth head-to-head.
Initial results are ok, but not great:
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━┓
┃ Expression ┃ Mean ┃ Var ┃ Ratio ┃
┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╋━━━━━━━━━━━╋━━━━━━━━━━━━╋━━━━━━━━━━━━━┫
┃ (execute :small :prefix-tree) ┃ 102.94 µs ┃ ± 9.90 µs ┃ 100.0 % ┃ (fastest)
┃ (execute :small :sawtooth) ┃ 109.25 µs ┃ ± 4.89 µs ┃ 106.1 % ┃
┃ (execute :medium :prefix-tree) ┃ 943.94 µs ┃ ± 23.98 µs ┃ 917.0 % ┃
┃ (execute :medium :sawtooth) ┃ 1.13 ms ┃ ± 33.57 µs ┃ 1,101.4 % ┃
┃ (execute :large :prefix-tree) ┃ 94.68 ms ┃ ± 1.20 ms ┃ 91,975.2 % ┃
┃ (execute :large :sawtooth) ┃ 113.50 ms ┃ ± 2.55 ms ┃ 110,254.1 % ┃ (slowest)
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┻━━━━━━━━━━━┻━━━━━━━━━━━━┻━━━━━━━━━━━━━┛I thought the up-front costs of sawtooth would be offset by the messiness at the end of prefix-tree.