Take a fairly normal Iguana interface that receives a message and writes some of it to a database.
The useful part is quite small. Read a few values from the message, convert them into the format the database expects, and insert or update the record.
But that isn’t all the Lua we ended up with.
We also need to open the database connection, make sure it is still available, handle the error if it isn’t, log enough information to work out what happened, and make sure everything is closed properly afterwards. If the interface needs to retry, that needs to be dealt with as well.
None of this is unusual code. In fact, that is really the point. It is code for exactly the same problems that every database interface has.
I have been looking at this while starting to move our Iguana channels to Integration Soup. When I create the database step there, the connection and the normal failure handling belong to the engine. I configure what I want to do and concentrate on the values I want to write.
The result is that most of the old Lua doesn’t need to be converted at all. It wasn’t business logic. It was just everything we had written around the business logic to make it safe to run.
I must admit, the large Lua libraries had always made the interfaces feel quite powerful. If we needed something, we could code it. That is still useful, but it also meant we took responsibility for a lot of things that would probably have been better handled by the integration engine.
It also makes later changes harder than they need to be. We have some old TCP interfaces where TLS now needs to be added. With our own implementations, each one has to be checked and updated. In Integration Soup it is a connection setting, so the same tested implementation is used throughout.
There will still be places where I use code. Some mappings and unusual rules are simply easier that way. But I would much rather use code for the bit that makes an interface different, and let the engine look after the bits that are the same every time.
That is probably the biggest improvement I have seen from the conversion so far. I’m not losing the useful code. I’m finding out how much of the other code I no longer need.