openresty / meta-lua-nginx-module

Meta Lua Nginx Module supporting both Http Lua Module and Stream Lua Module
66 stars 20 forks source link

Rename subsystem to subsys #10

Closed agentzh closed 6 years ago

agentzh commented 6 years ago

The word "subsystem" is too long and too heavy and appears so many times in all the templates and directory and file names. Let's abbreviate it to "subsys". Also, there is all-upper-case form like the SUBSYSTEM tt2 variable.

agentzh commented 6 years ago

Maybe we should use tools to do this edit otherwise it would be too much work considering the coding style :)

dndx commented 6 years ago

Agreed. Actually, there are couple of forms that appears very often in the templates. I think we can make the templates much easier to write by creating specific template directives for those:

Checking http subsystem

Current

[% IF subsystem == "http" %]
[% END %]

Proposed

[% HTTP %]
[% END %]

Checking stream subsystem

Current

[% IF subsystem == "stream" %]
[% END %]

Proposed

[% STREAM %]
[% END %]

Checking http subsystem with else

Current

[% IF subsystem == "http" %]
[% ELSIF subsystem == "stream" %]
[% END %]

Proposed

[% HTTP %]
[% ELSE %]
[% END %]

Uppercase form for macros

Current

#define NGX_[% subsystem FILTER upper %]_FOO_BAR

Proposed

#define NGX_[% SUBSYS %]_FOO_BAR

I don't think replacing them will be terribly difficult though. Most of those use cases are very consistent and should be a matter of seding all occurrences. If we can get rid of just the ones listed here plus renaming subsystem to subsys, the template's readability will definitely become a lot better.

@agentzh What's your opinion on this?

agentzh commented 6 years ago

@dndx Well, we still need to make it valid TT2 syntax. This is not bad:

[% IF http_subsys %]
[% ELSIF stream_subsys %]
[% END %]
agentzh commented 6 years ago

And indeed, [% subsystem FILTER upper %] should die and get replaced by [% SUBSYS %].

agentzh commented 6 years ago

Already done once #22 is merged.