Giter Site home page Giter Site logo

mini-poller's Introduction

mini-poller

A simple demonstration of how polling can be done asyncronously as a service. This uses async methods from Python, publishes messages into a Message Queue (RabbitMQ is used here) and inserts persistent content into MongoDB.


Instructions

Before running this program, you need to have Docker installed on your machine.

Start all containers for this service using:

cd mini-poller
docker-compose up -d

All necessary setup will be done automatically by Docker.

A sample web view is provided using Flask, to simply keep the main container alive. Going to localhost will simply give you an index page.

Now open 2 different terminals, for spawning both the producer and the consumer

You need to connect to the app docker container from both the terminals:

docker exec -it mini-poller_app_1 /bin/bash # On both terminal 1 and terminal 2

On the first terminal, start the consumer:

cd /usr/src/app
python poll_consumer.py

On the second terminal, start the core service:

cd /usr/src/app
python poll_service.py

Notice that I start the consumer first, so that it is ready for any published messages from the poll service.

Immediately, you'll start observing the polling changes in action!


Methodology

  • There are two programs:
  1. poll_service.py: Consists of the main service, which does the actual polling and publishes messages
  2. poll_consumer.py: A listener which retrieves incoming messages and stores them into DB.

The poll service basically keeps requesting a list of API endpoints and publish messages into RabbitMQ.

The poll consumer will keep listening to incoming messages on that channel and insert any records into MongoDB directly.


mini-poller's People

Contributors

kuriringohankamehameha avatar

Watchers

 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.