Hello,
although is more part of devel, the decision will affect users of future stable releases, so I posted on both lists.
Maybe some of you noticed that in the ongoing process of improving the pseudo-variables system, the AVPs and HDRs can be accessed with dynamic index. That means next lines are correct in the config file.
$var(i) = 1; xlog("$(avp(i:20)[$var(i)])");
if($(avp(i:20)[$var(i)]) == 3) { }
In the past, the index was static, as a number.
The question I want to address is whether makes sense to add 'while' statements to iterate through avps or hdrs. More or less, the cycles can be done via recursive routes.
The block:
$var(i) = 0; while($(avp(i:20)[$var(i)]) != null) { ..... $var(i) = $var(i) +1; }
is equivalent with:
$var(i) = 0; route(1); .... route[1] { if(($(avp(i:20)[$var(i)]) == null) return; ... $var(i) = $var(i) +1; route(1); }
'while' may look more attractive, but could open the pandora box, people asking for more and more, that will turn config language is something very complex (not saying that is simple now :-) ).
The drawback with recursive routes is the fixed number of routes that can be defined with the standard openser: 40 (number can be increased if openser is recompiled), because for each cycle another route has to be used.
Waiting for your opinions...
Cheers, Daniel
El Martes, 11 de Septiembre de 2007, Daniel-Constantin Mierla escribió:
The block:
$var(i) = 0; while($(avp(i:20)[$var(i)]) != null) { ..... $var(i) = $var(i) +1; }
is equivalent with:
$var(i) = 0; route(1); .... route[1] { if(($(avp(i:20)[$var(i)]) == null) return; ... $var(i) = $var(i) +1; route(1); }
'while' may look more attractive, but could open the pandora box, people asking for more and more, that will turn config language is something very complex (not saying that is simple now :-) ).
The drawback with recursive routes is the fixed number of routes that can be defined with the standard openser: 40 (number can be increased if openser is recompiled), because for each cycle another route has to be used.
Waiting for your opinions...
Some days ago I needed to do a SQL query in OpenSer. This query returns various rows, and I need to check a column and in case of match then take the value of other column in same row. That was not possible with actual AVP ops, and sincerely I don't want to do recursive routing for this (too much complex and strange for something really simple). At the end I used "exec" module and an external script (really a not elegant solution).
So in my opinion a simple "while" (or "for") function could be just great.
Regards.
Hi Daniel!
IMO a while loop is a good idea. But I think a maximum loop counter should be added too (maybe as parameter at top of openser.cfg) which stops the loop and discards the message e.g. after 100 iterations to prevent an endless loop.
regards klaus
Daniel-Constantin Mierla schrieb:
Hello,
although is more part of devel, the decision will affect users of future stable releases, so I posted on both lists.
Maybe some of you noticed that in the ongoing process of improving the pseudo-variables system, the AVPs and HDRs can be accessed with dynamic index. That means next lines are correct in the config file.
$var(i) = 1; xlog("$(avp(i:20)[$var(i)])");
if($(avp(i:20)[$var(i)]) == 3) { }
In the past, the index was static, as a number.
The question I want to address is whether makes sense to add 'while' statements to iterate through avps or hdrs. More or less, the cycles can be done via recursive routes.
The block:
$var(i) = 0; while($(avp(i:20)[$var(i)]) != null) { ..... $var(i) = $var(i) +1; }
is equivalent with:
$var(i) = 0; route(1); .... route[1] { if(($(avp(i:20)[$var(i)]) == null) return; ... $var(i) = $var(i) +1; route(1); }
'while' may look more attractive, but could open the pandora box, people asking for more and more, that will turn config language is something very complex (not saying that is simple now :-) ).
The drawback with recursive routes is the fixed number of routes that can be defined with the standard openser: 40 (number can be increased if openser is recompiled), because for each cycle another route has to be used.
Waiting for your opinions...
Cheers, Daniel
Users mailing list Users@openser.org http://openser.org/cgi-bin/mailman/listinfo/users