Imagine such a scenario:
There are 2 companies(dealer and supplier), each one using their own websites.
I want to create a service between them.
My service will periodically fetch new product request from the dealer’s API and send the product request to the supplier’s API. Also, the service will periodically check sent product requests from supplier’s API and if there is a change about the sent products on the supplier’s website the service will send related changes to dealer’s API.
I don’t know exactly what is the best way of handling this type of scenario.
What do you think about building a structure like this:
Start 2 GenServers for each dealer<=>supplier binary when application started.
I think creating two separate genserver will provide me separation of dealer/supplier related code from each other.
- Fetch new products from dealer API(periodically) - Send product changes sent by supplier genserver to dealer API.
- Fetch product changes from supplier API(periodically). - Send the changes to dealer genserver.
So data flow will be like this:
DealerAPI <-> DealerClient <-> SupplierClient <-> SupplierAPI
Also there are multiple dealers and multiple suppliers(OneToOne relation), so each dealer process should know
her supplier’s process to send or fetch data from.
- This structure is good? If not what would you do if you were me? What kind of structure would you build?
- How to handle dynamic process linking? How does dealer process know her supplier’s process?
- Should I create a supervisor for each dealer<=>supplier binary?
Sorry about my poor English.