[sr-dev] Kamailio 5-0 - Executing event routes in embedded languages

Daniel-Constantin Mierla miconda at gmail.com
Wed May 4 09:34:39 CEST 2016


Hello,

as announced earlier this morning, most of the routing blocks can be
written directly in an embedded language (right now supported being Lua
and Python). The missing blocks are (most of) the event routes.

The event route from tm for branch failure route is already supported,
as the name has to be set via t_on_branch_failure(...).

In the native configuration, event routes are executed if they are
defined. Their names (as in event_route[name]) are not valid function
names for the other programming languages to be used directly
corresponding callback function name.

I was thinking of the alternative, next are the ones I came up with,
more suggestions are welcome.

1) add parameters for event route callback names, like:

modparam("htable", "evrtcb_mod_init", "ksr_htable_mod_init")

would define the name of the function for the alternative to
event_route[htable:mod-init].

This has a benefit in speed, if the parameter is not defined, then there
is no overhead in trying to execute a callback function in an embedded
language.

The drawback is that there is need to code a bit of C to add those
parameters to the components executing event routes.

2) do a direct mapping using some translation rules, like:

- prefix with ksr_
- replace ':' and '-' with underscore '_'

So event_route[htable:mod-init] will have automatically the
correspondent function ksr_htable_mod_init().

The drawback is that each time the even route should be called, a lookup
on embedded language symbols table needs to be done to see if it exists,
then execute it.

There is still some C code to do, but less than adding parameters like
for 1).

3) like 2), but instead of an automatic translation, keep a mapping table:

struct mapping {
  str kname;
  str ename;
} table[] = {
  str_init("htable:mod-init"),
  str_init("ksr_htable_mod_init"),

}

Adding a new event route will require adding a new record in the mapping
table. The benefit is that the function name in embedded language can be
selected to be whatever, with or without ties to the event_route name.

Opinions?

Cheers,
Daniel

-- 
Daniel-Constantin Mierla
http://www.asipto.com
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda
Kamailio World Conference, Berlin, May 18-20, 2016 - http://www.kamailioworld.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20160504/969ba9cd/attachment.html>


More information about the sr-dev mailing list