reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
ikitommi 2020-09-28T07:56:30.017600Z

@eyaldocs do you mean core/frontend or the backend coercion? will answer for both: • frontend: easy to add non-throwing variant • backend: few things to do: 1) ensure we use fast-throwing exceptions (e.g. no stack traces) 2) can add a non-throwing variant, BUT the invalid coercion response would need to be identified by all other middleware in chain as “non-success-case”. If you have a middlware that starts a transaction and coercion fails after it, that mw should rollback in case of coercion error.

ikitommi 2020-09-28T07:57:13.018500Z

async-ring doesn’t have to throw, you can just create an exception (without the stack trace) and pass it into to raise handler => just an object.

ikitommi 2020-09-28T08:25:33.024300Z

did you run the coercion flamegraphs with malli? happy to optimize the perf on that, Some things in mind: 1. derive optimized Jackson parser from malli schemas => parsing & coercion in single step, we can select just the data needed => 3+ steps less in transformations, less garbage 2. control reitit coercion key keywordization from coercion impl => now re-keywordizating all map-bodies 3. don’t throw on error, optimized responses

Eyal H 2020-09-28T08:36:35.024500Z

Thanks @ikitommi! I was referring to the backend. Do you have an example for this? (fast throwing exceptions and non-throwing variant)

ikitommi 2020-09-28T08:43:11.024800Z

filling the stack trace is really slow. Coercion could have a custom Exception type, without filling the stack trace: https://www.atlassian.com/blog/archives/if_you_use_exceptions_for_path_control_dont_fill_in_the_stac

Eyal H 2020-09-28T08:45:45.025100Z

Thanks. How do you set a custom exception type for the coercion

Eyal H 2020-09-28T08:46:26.025300Z

What about the option to not throw at all?

ikitommi 2020-09-28T08:51:23.025500Z

> BUT the invalid coercion response would need to be identified by all other middleware in chain as “non-success-case”. If you have a middlware that starts a transaction and coercion fails after it, that mw should rollback in case of coercion error.

ikitommi 2020-09-28T08:51:52.025700Z

need to solve that first. there is no non-throwing-raise in ring spesification, have to invent such.

ikitommi 2020-09-28T08:52:42.025900Z

the stackless custom coercion exception needs to be added to reitit itself, Issue/PR welcome.

Eyal H 2020-09-28T08:57:18.026100Z

Yes, adding a middlware that identifies the failure is not an issue. Isn't there an option in reiit where I can customize the coerce middleware not to throw the excetopn, just mark it as failed on the request (for example). Then. in a separate middleware, I can check for that flag and act accordingly

ikitommi 2020-09-28T09:02:28.026300Z

not yet, please write an issue, pr would be welcome too.

Eyal H 2020-09-28T09:02:44.026500Z

Ok, thanks a lot