Hi,
I have written a system that allows a business to enter basic details of a purchase. So far it is a simple CRUD system. Currently if the save operation works, then the user sees “Success”, otherwise they see “Failed” in a modal dialog. All pretty standard.
I have been asked to now sync data to a 3rd party service who takes care of warranty calls on the products the business sells.
Traditionally I would have probably written to the database and then made a call to the 3rd party to sync the data and used their result to determine whether data was synced to both database and 3rd party.
But I think I should probably approach this another way.
I was thinking:
- Add a boolean column to the order table to determine if it has been synced to 3rd party via POST request
- Create GenServer that keeps a lookout for orders that haven’t been synced
- Over time, the GenServer would sync them to the 3rd party and update the boolean column to “true”…
I have played with GenServer when I first started learning Elixir, but having only written pretty flat web applications since, I haven’t really come across needing to use them.
My thinking of using an approach like this is that the front end user doesn’t care about whether the order has been sent to the 3rd party, all they care about is whether it has been saved to the database or not - that the CRUD operation has successfully completed.
So I don’t see any reason why the above would not work, but seeing as I haven’t visited GenServers in a little while, I guess my question is… am I on the right path with this or would there be a better approach in Elixir that would do this job. My memory is telling me that there is something a little more suitable than a GenServer which is more suitable… but can’t recall what that might be.
Cheers,
Nathan