Google Groups

Best practice for deferred evaluation/batch processing of snippets


Colin Dellow Apr 11, 2012 7:07 AM
Posted in group: Lift
I need to do an expensive operation (a DB request, a file system
check), potentially N times. I'd like to batch up the requests so I
only pay the network latency cost once.  This works if only a single
massive snippet is reponsible for all the requests, but not so well if
multiple snippets contribute to the final document, all of which may
need to do the operation.

Is there a way to defer snippet evaluation until the last minute,
where a method has access to the entire output and can batch things
up?

The approach I'm currently thinking of is to emit something like
<makeLink id="baz"/>, hook into LiftRules.convertResponse and do a
transformation there, which feels a bit dirty.