Difference between invoking inline fn and transformer

:slight_smile: Hi all,
Could anyone please tell me in brief about the difference between using a service as an inline function and using it as a transformer.

I have heard my seniors saying, invoking service as a transformer will improve the performance as well as reduce the complexity as the pipeline out variables of the transformer won’t have scope after that and we need not drop it explicitly.

But in some scenarios from my personal experience i feel, things go wierd when invoking service as a transformer. Variables from the main service are not preserved when invoking a service as a transformer.

Can anyone pls advice.
Thanks in advance,
Krithiga

Performance used to differ, but it doesn’t any more. IMO, one doesn’t use transformers (or avoid them) for performance reasons. Although the documentation implies this, transformers are not run in separate threads nor do they run in parallel. The intent of the documentation was to emphasize that the order of execution of the transformers is not defined/guaranteed.

The only benefit, IMO, is that the pipeline visibility is limited–the service invoked as a transformer sees only the vars explicitly passed to it, and output vars must explicitly be mapped out to the calling service’s pipeline. This, as you mention, can reduce pipeline clutter.

Can you elaborate on “Variables from the main service are not preserved…”? Variables in the calling service will not be affected in any way unless you explicitly map from/to them. If the calling service has var named “foo” the transformer will never see that var (unless it is declared as an input and mapped in). The transformer can do anything it wants with its own var named “foo” and it will not impact the calling service variable. Even if “foo” is passed in and the tranformer modifies it, the value of foo will not change in the calling service unless you map it from the output of the transformer.

Thanks Reamon :slight_smile: