You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To give a design understanding of my code. There is a server, supervisor and client that all have their own loops. The server can be started without the supervisor with frequency:start/0. If the server fails, it will not be restarted. To start the server with a supervisor, you can do so with frequency:sup_start/0. To simulate clients, use frequency:sim_clients(N). You can simulate N number of clients running. The function returns the Pids of the spawned processes.
Things to note:
Because of the timeouts, you'll notice that if you spawn 3 process, you won't always use 3 frequencies. Some times a process will be sleeping so only 2 or 1 process may be running. You can alter the sleep calls accordingly to change this.
I register the atom io with the main pid (i.e. the shell) so that logging can be sent back to it with ease.
I've added a lot of logging during each attempt/failure so it might be too verbose for you. Comment some out accordingly.
In my solution I used a simple round robin implementation to choose between the two servers. I separated the balancer module from the frequency to make the implementation cleaner. I've also moved allocated/0 and deallocated/1 to this module since they are the interfaces.
Scaling up
Suppose that the frequency server needs to serve more frequencies. It would be possible to do this just by having a longer list of frequencies available, but it is likely that this scaling is required not only because more frequencies are needed but also because there are more requests to allocate and de-allocate them.
Get the total spent from an exported CSV on Presto (prestocard.ca)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Output of `exa -Td --ignore-glob="*.kt"` as of 15/12/20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters