Hi! I’m Ruby developer that was invited to work with Elixir. The company gave me a task to build a shop application (actually it’s not a shop application - I changed the task to not share the real one):
Functions are:
- create_customer(name, amount_of_money)
- buy_product(customer_name, product)
- return_product(customer_name, product)
- ...
Requirments:
- Usual OTP app with data in memory without any databases or disk storage
- The system should handle 5 or fewer operations for one customer in a single moment. If there are more than 5 operations in a pending state then an error should be returned
- The system should able to work with several customers simultaneously without performance impact on each other
I’ve read the official introduction and most of the https://codestool.coding-gnome.com/courses/take/elixir-for-programmers/ course but still don’t really understand how to build the app.
For every customer, I want to make a process that holds an amount of money.
What I don’t understand:
- How to make tests to check that there is an error message if there are more than 5 operations? I can spawn 6 processes but they run fast - will it be correct?
- How to track how many processes use a customer? In a Customer server with GenServer hooks?
- Should I use Supervisor? If a customer process dies then all the data will be lost
- Should a customer be in a separate node or just using GenServer is enough?
How you can help me:
- Suggest me a book/article/course that can explain the topic better (I’m thinking about “Elixir in Action”)
- Suggest me simpler projects that I can make on my own before doing this one