@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.
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.
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
Thanks @ikitommi! I was referring to the backend. Do you have an example for this? (fast throwing exceptions and non-throwing variant)
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
Thanks. How do you set a custom exception type for the coercion
What about the option to not throw at all?
> 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.
need to solve that first. there is no non-throwing-raise in ring spesification, have to invent such.
the stackless custom coercion exception needs to be added to reitit itself, Issue/PR welcome.
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
not yet, please write an issue, pr would be welcome too.
Ok, thanks a lot