Coder Social home page Coder Social logo

iuracpersonal / kitchen-component Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 25 KB

π™Ίπš’πšπšŒπš‘πšŽπš— π™²πš˜πš–πš™πš˜πš—πšŽπš—πš

Dockerfile 1.69% Python 98.31%
flask networking python threading

kitchen-component's Introduction

KITCHEN SERVER

INSTALLATION

!NOTE: take the next steps only once, but I will put them in both component’s README for better convenience.

In order to run the docker servers using docker compose do the following steps:

Linux/Unix

  1. Open your terminal and paste:
mkdir restaurant-simulator

I will add the links after I configure everything.

cd restaurant-simulator
touch docker-compose.yml
  1. Paste the following into the docker-compose.yml file.
version: '3'

services:
  kitchen_1:
    build: ./kitchen-server
    ports:
      - "3111:3111"
    environment:
      - USING_DOCKER_COMPOSE=1
      - RESTAURANT_ID=1
    depends_on: 
      - restaurant-aggregator
    
  kitchen_2:
    build: ./kitchen-server
    ports:
      - "3222:3222"
    environment:
      - USING_DOCKER_COMPOSE=1
      - RESTAURANT_ID=2
    depends_on: 
      - restaurant-aggregator

  # dining-hall:
  #   build: ./dining-hall-server
  #   ports: 
  #     - "8080:8080"
  #   environment:
  #     - USING_DOCKER_COMPOSE=1
  
  restaurant-aggregator:
    build: ./restaurant-aggregator-server
    ports:
      - "7777:7777"
    environment:
      - USING_DOCKER_COMPOSE=1
      
  client-server:
    build: ./client-server
    ports:
      - "3333:3333"
    environment:
      - USING_DOCKER_COMPOSE=1
    depends_on: 
      - restaurant-aggregator
      - kitchen_1
      - kitchen_2
  1. Start the Docker service:
sudo systemctl start docker
  1. Then run the command:
sudo docker compose up --build

Windows

  1. Create a folder restaurant-simulator.
  2. Open a Terminal/Git Bash in that folder.
  3. Paste the following line by line:
I will add the links after I configure everything.
  1. Create a new file docker-compose.yml in the restaurant-simulator folder.
  2. Add the following to the previously created file:
version: '3'

services:
  kitchen_1:
    build: ./kitchen-server
    ports:
      - "3111:3111"
    environment:
      - USING_DOCKER_COMPOSE=1
      - RESTAURANT_ID=1
    depends_on: 
      - restaurant-aggregator
    
  kitchen_2:
    build: ./kitchen-server
    ports:
      - "3222:3222"
    environment:
      - USING_DOCKER_COMPOSE=1
      - RESTAURANT_ID=2
    depends_on: 
      - restaurant-aggregator

  # dining-hall:
  #   build: ./dining-hall-server
  #   ports: 
  #     - "8080:8080"
  #   environment:
  #     - USING_DOCKER_COMPOSE=1
  
  restaurant-aggregator:
    build: ./restaurant-aggregator-server
    ports:
      - "7777:7777"
    environment:
      - USING_DOCKER_COMPOSE=1
      
  client-server:
    build: ./client-server
    ports:
      - "3333:3333"
    environment:
      - USING_DOCKER_COMPOSE=1
    depends_on: 
      - restaurant-aggregator
      - kitchen_1
      - kitchen_2
  1. Make sure to have Docker Desktop started.
  2. Run
docker-compose up --build

ABOUT

The Kitchen has a finite order list. This order list is shared across all kitchen instances. All orders which kitchen receives have to be added to a single instance of order-list.

Main work unit of the Kitchen are cooks. Their job is to take the order and β€œprepare” the menu item(s) from it, and return the orders as soon and with as little idle time as possible. Kitchen can prepare foods from different orders and it is not mandatory that one cook have to prepare entire order. Order is considered to be prepared when all foods from order list are prepared.

Each cook has the following characteristics:

  • rank: which defines the complexity of the food that they can prepare (one caveat is that a cook can only take orders which his current rank or one rank lower that his current one):
    • Line Cook ( rank = 1 )
    • Saucier ( rank = 2 )
    • Executive Chef (Chef de Cuisine) ( rank = 3 )
  • proficiency: it indicates on how may dishes he can work at once. It varies between 1 and 4 (and to follow a bit of logic, the higher the rank of a cook the higher is the probability that he can work on more dishes at the same time).
  • name
  • catch phrase

So a cook could have the following definition:

{
    "rank": 3,
    "proficiency": 3,
    "name": "Gordon Ramsay",
    "catch-phrase": "Hey, panini head, are you listening to me?"
}

KITCHEN_V2

Register each Restaurant to the Aggregator.

_ = requests.post(
    url=f'http://restaurant-aggregator:7777/register',
    json={
        'restaurant_id': RESTAURANT_ID,
        'name': RESTAURANT_CFG[RESTAURANT_ID]['name'],
        'address': f'http://{RESTAURANT_CFG[RESTAURANT_ID]["HOST_NAME"]}:{RESTAURANT_CFG[RESTAURANT_ID]["DINING_HALL_PORT"]}',
        'menu_items': len(RESTAURANT_CFG[RESTAURANT_ID]['menu']),
        'menu': RESTAURANT_CFG[RESTAURANT_ID]['menu']
    }
)

MORE DETAILS

The Kitchen consists of order list, cooks and cooking apparatus. The order list should be a single instance which holds all orders received from Dinning Hall .

The Kitchen should handle HTTP (POST) requests of receiving orders from the Dinning Hall and add received order to order list . For all received orders kitchen have to register time it was received and time is was totally prepared. Cooking time should be added to order before sending it back to Dinning Hall.

Cooks should be an object instances which run their logic of preparing foods on separate threads , one thread per cook .

Your task is to design a mechanism which will prepare orders by using cooks as work unit. It is up to you to decide how orders will be managed and how foods will be assigned to cooks in order to be prepared. Your main goal is to reduce preparation time of each order.

The kitchen has a limited number of cooking apparatus and in our case we will use only stoves and ovens. Cooking apparatus should be object instances which work independently and in parallel. Cooking apparatus are sharable resources across all cooks and you have to carefully use them.

Number and types of cooks and cooking apparatus should be configurable.

When order is prepared, meaning that all foods from order are prepared. Kitchen should perform HTTP (POST) request with prepared order details to Dinning Hall in that way returning prepared order to be served to the table.

LINKS

CONTACT

If you have any question, please contact me through email: [email protected].

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.