Giter Site home page Giter Site logo

foobartory's Introduction

Foobartory

Python3.6+ compatible Documentation Status Continuous Integration Status Coverage Status MIT License Code style black

An actor model to simulate an automated production chain using Python asyncio.

Here's an example

The foobartory CLI

Quickstart

$ git clone [email protected]:thomasperrot/foobartory.git
$ cd foobartory
$ pip install .

Once you have installed the package, you can run the Foobartory with the following command:

$ foobartory --speed=10 -v

To have details about the available options:

$ foobartory --help
Usage: foobartory [OPTIONS]

Options:
  -s, --speed FLOAT  Fasten the factory by the given factory (1 by default)
  -v, --verbose      Use multiple times to increase verbosity  [x>=0]
  --help             Show this message and exit.

Improvements

I chose to implement this project using Python asyncio. This is a simple and efficient approach, but it could be improved. In particular, a major improvement would be to use a micro-services architectures, where each robot is an independent process. The project would then follow a master slave achitecture, where the master is the Factory, and the slaves are the robots.

  • Each robot is an independent process, that would run synchronous Python code, packaged in Docker.
  • The factory is also an independent process, running synchronous Python code on the host machine.
  • Each robot sends Foo, Bar, FooBar and cash to RabbitMQ independent exchanges. Those four exchanges each have a unique queue, which is listen by all robots.
  • When a robot wants to buy a new robot, it sends a message in a RabbitMQ exchange to inform the factory. This exchange is common to all robots, and have a single queue, which is listen only by the factory.
  • The Factory is in charge of:
    • starting new robots when receiving a message on the dedicated queue. To do this, the factory can use docker-py package
    • stopping robots once 30 robots have been bought. To do this, the Factory sends a stop message to a dedicated exchange, which has one queue per robot. Every robot must stop when a message is received on that queue.

In a production environment, we could even run the robots in GCP (Cloud Run or Kubernetes). Unfortunately, I did not have enough time to implement it.

Where to go from here

The complete docs is probably the best place to learn about the project.

If you encounter a bug, or want to get in touch, you're always welcome to open a ticket.

foobartory's People

Contributors

thomasperrot avatar

Watchers

 avatar  avatar

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.