Hi and happy new year to all of you
I am currently working on some microservices, that configure ISP services and reached the following “problem” for a seemingly simple task:
A radius server has multiple tables with the same MySQL data structure (id(PK, auto_increment), username, attribute, operator and attribute_value). Some are for user authentication, others are for authorization and connection setup. The radius sql plugin defines simple, single table queries (by design to handle >10.000 logins and parallel accountings as fast and efficient as possible when an ISP uses NDB)
As I’m (quite) new to Elixir, I’m considering the most elegant way to implement this for 4-6 table schemas (at the moment).
The easiest way (4-6 modules) feels a bit clunky, so I thought, there must be a better way.
My next idea was to use an embedded_schema in a macro and/or define the CRUD functions as callbacks, but I’m bound to foreign keys then, if I got the ecto documentation right.
Currently I consider moving all in one ParameterEntry module and use the {struct, source: “”} notation and Ecto.put_meta/2 for table operations. This would be more DRY, and looks cleaner at first glance, but then there may also be a lot of hardcoding table names in calls.
As I use this (admittedly, quite ambitious) project not only to make my employer happy, but also as a “real life” learning source, I’d be glad, if someone could give me a nudge in the right direction, if there is a better way.