Fork me on GitHub
#reitit
<
2019-02-08
>
msolli07:02:29

We have a fairly large set of routes, and many of them follow the usual (?) REST practice of naming the resource in the plural: /foos, /bars, etc. Adding a new Foo means POSTing to /foos, and retrieving Foo with id 42 means GETting /foos/42. Now, another usual practice in web apps is to have forms for creating and editing Foos at /foos/new and /foos/42/edit. With Reitit the /foos/new route causes a conflict with the /foos/:id route. The conflict resolution can be disabled with {:conflicts nil}, creating a :quarantine-router (where conflicting routes exists in a :linear-router). I don’t know the performance characteristics in my particular case, but it must be slower, though maybe negligible. How do you folks deal with this? Do you just bite the bullet and come of with some other scheme of organizing your URLs?

ikitommi07:02:12

the :quarantine-router is almost as fast as everything else. It takes only the routes in conflicts and quarantine those into linear router (which is also backed by a Trie). All non-conflicting routes are as fast as before. If the conflicting paths have wildcards, the perf penalty is negligible. If the conflicting routes are static, then there is a small degrade, but just for the conflicting ones.

ikitommi07:02:09

… and the perf degrade with the upcoming new Trie impl is mayby 2-3 times slower only. e.g. 20ns -> 60ns. Could add a perf test for this. But, should be ok perf-wise.

msolli08:02:13

Thanks, that’s good to know.