Tuesday, February 8, 2011

Day 15 - no loops in nginx. Or it's inconscious...

Life can be ironic sometimes. I'm almost done with the translation and I find out about this great tool : Google translator toolkit. This is very easy to use. Or, at least much easier than what I was doing with 10 tabs open on google translate and yahoo babelfish. I am no professional translator but from what I can see, I'm pretty sure the guys who designed the user interface of this were (or at least got a good
enough knowledge of the job to understand what was need). Doesn't happen too often, so I figured I would point that this is a good example of a user interface design that matches the need. The other examples that come to my mind are IntelliJIDEA when they introduced the refactoring features (yeah, that was a few years before Eclipse made them popular) and zen coding.

So, here I am, almost at the end of the document, working on configurations and, coming out of nowhere, here they are again : variables... Argh!!! Well, of course it makes sense that modules can define their own variables but this is not something I was expecting at all. Well, the example in Valery's document is not making a lot of sense to me (it's for setting variable "var"). So, I spent a little time to fish an example from the code. But that's not my point (so see below for the example). Besides the irony of it, my point is that I finally got the answer to one of my 'unanswered questions': what is a variable (see Day 7 - bye bye buffers, hello variables) through this sentence "To generate a variable, you must implement a function that fills the ngx_http_variable_value_t structure using data from a query, from the context, from the configuration of the module or from other sources.". So, a variable is pretty much a name and a value and the value can come from anywhere...

I mentioned an example of variable defined by a module: $modern_variable defined by the Http Browser module. The whole purpose of this module is to let the person writing the configuration decide what a modern browser is, provide this in the configuration and nginx makes $modern_variable available with the right value on each request.

Now, as far as the title of this post goes: nginx has no loop construct in its configuration language. But the irony of today's discoveries made me wonder if at some level nginx is not having me go circles.

No comments:

Post a Comment