[SR-Users] Tips on picking random element from a list

Joel Serrano joel at textplus.com
Tue May 3 18:19:41 CEST 2022


Hi Everyone,

I have to implement a flow where outbound calls get their caller-id set
with a random number from a pool.

I've been looking around and, as most of the time, there are tons of ways
to implement something like this... This is a simple implementation, the
number pool is fixed and will not change (so I could have it hard-coded in
the config if required).

My initial approach was:

1- Try to keep it simple, with no dependencies, and all done in the config
script.
2- If #1 is "ugly", then I'd probably go with some inline code using
python/lua/etc
3- If #2 is "ugly", then I'd go with having the info in a DB and just run a
query

I think #2 and #3 might be overkill for something so "simple" but I haven't
had to work too much with randomness in Kamailio, so any tips/suggestions
on where to store the number list and how to pick one randomly would be
awesome!

Thanks!!
Joel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20220503/352ccd66/attachment.htm>


More information about the sr-users mailing list