Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code template inclusion is no longer restricted by the template scope (Message/Channel/etc.) #3063

Closed
rbeckman-nextgen opened this issue May 11, 2020 · 5 comments
Milestone

Comments

@rbeckman-nextgen
Copy link
Collaborator

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

In 2.x, the inclusion/exclusion of certain context types was different across the board. Some scripts included all functions, some didn't. Currently in 3.x, all function code templates are being included all the time. So in general it shouldn't cause any problems, but it's still possible for things to break from 2.x to 3.x if the user was dependent on certain templates not being included in certain scopes. Remember that you don't have to only include function definitions in a function code template. You can include any arbitrary code you want, and that code will be compiled in with your channel's scripts, such that when the scripts run, the code template code will also run.

I think part of this may be figuring out / deciding what the different context types should mean (MIRTH-1547).

Imported Issue. Original Details:
Jira Issue Key: MIRTH-3150
Reporter: narupley
Created: 2014-02-14T21:36:43.000-0800

@rbeckman-nextgen rbeckman-nextgen added this to the 3.0.2 milestone May 11, 2020
@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

So the comparison being done in appendCodeTemplates appears to be correct now, but the bigger problem is that the actual context used is always Global. Instead compileAndAddScript in JSU should take in the context, and each place that needs to compile scripts should be explicitly passing it in.

Imported Comment. Original Details:
Author: narupley
Created: 2014-04-01T11:12:36.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Revision 7125: Fixed function code template inclusion so that it works the same as it did in 2.x. The only differences are that Channel code templates are now available in the channel deploy/shutdown/preprocessor/batch scripts where they weren't available before. The attachment script (new in 3.x) allows Channel or higher, and the response transformer (also new) allows Message or higher (i.e. all templates).

In the global scripts panel, we're now actually restricting the available templates shown in the UI to only Global Channel or Global. This is because although Channel templates are available for the postprocessor, they aren't available for the other scripts, and the panel doesn't differentiate between different script types when showing the reference list.

To hopefully make it a bit easier to understand, here's what 2.x allowed:
\
\
||Script||Message||Channel||Global Channel||Global||
|Global scripts (-post)|N|N|Y|Y|
|Global postprocessor|N|Y|Y|Y|
|Channel scripts (-post)|N|N|Y|Y|
|Channel postprocessor|N|Y|Y|Y|
|Batch|N|N|Y|Y|
|Filter/Transformer|Y|Y|Y|Y|
|JavaScript Reader|Y|Y|Y|Y|
|JavaScript Writer|Y|Y|Y|Y|
|Database Reader|Y|Y|Y|Y|
|Database Writer|Y|Y|Y|Y|
|Database Reader ACK|Y|Y|Y|Y|
\
And here's what 3.0.2 will allow:
\
\
||Script||Message||Channel||Global Channel||Global||
|Global scripts (-post)|N|N|Y|Y|
|Global postprocessor|N|Y|Y|Y|
|Channel scripts (-post)|N|{color:red}Y{color}|Y|Y|
|Channel postprocessor|N|Y|Y|Y|
|{color:red}Attachment{color}|{color:red}N{color}|{color:red}Y{color}|{color:red}Y{color}|{color:red}Y{color}|
|Batch|N|{color:red}Y{color}|Y|Y|
|Filter/Transformer|Y|Y|Y|Y|
|{color:red}Response Transformer{color}|{color:red}Y{color}|{color:red}Y{color}|{color:red}Y{color}|{color:red}Y{color}|
|JavaScript Reader|Y|Y|Y|Y|
|JavaScript Writer|Y|Y|Y|Y|
|Database Reader|Y|Y|Y|Y|
|Database Writer|Y|Y|Y|Y|
|Database Reader ACK|Y|Y|Y|Y|

Imported Comment. Original Details:
Author: narupley
Created: 2014-04-09T16:05:33.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Verified

Imported Comment. Original Details:
Author: wayneh
Created: 2014-04-14T09:42:25.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

So why not just set them all to global? What is being gained by shortening the scope?

Imported Comment. Original Details:
Author: stickybandit
Created: 2014-05-08T15:13:31.000-0700

@rbeckman-nextgen
Copy link
Collaborator Author

@rbeckman-nextgen rbeckman-nextgen commented May 11, 2020

Certain templates only make sense within the context of a filter or transformer script, specifically ones having to do with mapping E4X fields to or from msg/tmp. So it's just meant for convenience, and so that all code templates aren't necessarily compiled in with all scripts. Currently Message-context code templates aren't compiled in with the channel/global scripts (pre/post/deploy/shutdown). If you set everything to global, then they will get included unnecessarily.

And just to clarify, no scopes were shortened; if anything they were expanded because the batch script and channel postprocessor scripts now have access to Channel-context code templates.

Imported Comment. Original Details:
Author: narupley
Created: 2014-05-08T15:54:26.000-0700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.