Skip to content

jfgulden/concurrent-programming-ecommerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date Open in Visual Studio Code

23C2-Rust-eze

Repo for Concurrentes FIUBA

Files Creation

Before compiling and running the program, we must create some files:

Orders

  • an pedidos/[ecom_orders_filename].txt for each ecom, which will contains all the online orders, with the following format:
<ecom_id>
----------------------
<order1_product_name>,<quantity>,<purchase_zone>
<order2_product_name>,<quantity>,<purchase_zone>
...
<orderN_product_name>,<quantity>,<purchase_zone>

An example of it is shown at pedidos/ecom1.txt

  • A pedidos/[shop_filename].txt for each shop, which will contains all the local orders, with the following format:
<order1_product_name>,<quantity>
<order2_product_name>,<quantity>
...
<orderN_product_name>,<quantity>

An example of it is shown at pedidos/tienda1.txt

Shops

  • A tiendas/[shop_filename].txt for each shop, which will contains all the local stock, with the following format:
<shop_zone_name>,<shop_address:port>,<shop_zone_id>
----------------------
<stock1_product_name>,<quantity>
<stock2_product_name>,<quantity>
...
<stockN_product_name>,<quantity>

An example of it is shown at tiendas/tienda1.txt

Compile and run

First, we should run the shop binary:

cargo run --bin shop [shop_filename]

example: cargo run --bin shop tienda1

Then, we should run the ecom binary:

cargo run --bin ecom [ecom_orders_filename]

example: cargo run --bin ecom ecom1

If we do so, the shop will start listening for online orders while it processes local orders, and the ecom will be sending those online orders to the shop. If we run the ecom but we don't run any shops, the ecom will try to send the orders and it won't be able, so all of them will be rejected.

Ecom shortcuts

We can disconnect shops from the ecom by pressing 's[shop_zone_id]', and pressing the enter key. We can try to reconnect to a shop from the ecom by pressing 'r[shop_zone_id]', and pressing the enter key.

For example:

``` s1 ```
Disconnects shop 1 from the ecom
``` r1 ```
Tries to (re)connect shop 1 to the ecom

With these shortcuts we can play with the execution orders of the ecom and the shops, and see how they behave.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages