Coder Social home page Coder Social logo

rosselsprung's Introduction

Running Rosselsprung with Docker Compose

First we need to 'clone' repository with command:

git clone https://github.com/vladimirc81/rosselsprung.git
cd rosselsprung

After this - we start docker-compose command with:

docker-compose up -d --build

This command would build images (if they are not allready in docker images) and run as daemon - exposing ports 80 and 5432

if we have images (app and ratestask) in our docker images we run:

docker-compose up -d

In case there is need to view output from containers we just run:

docker-compose up

After we finish running container we can shutdown with:

docker-compose down

REST API

Description: METHOD GET - used for searching avg prices between two ports. We have origin and destination This metod use:

/v1/rates/<date_from>/<date_to>/<origin>/<destination>/ 

METHOD POST - used for insertion prices into DB. For this method we can only use code. This method use:

/v1/rates/<date_from>/<date_to>/<orig_code>/<dest_code>/<int:price>/

METHOD GET - search avg prices

We want to view avg prices for each day , origin port CNGGZ - destination port EETLL

curl -X GET http://127.0.0.1/v1/rates/2016-01-01/2016-01-02/CNGGZ/EETLL/

Response:

[
    {
        "day": "2016-01-01",
        "average_price": 1154
    },
    {
        "day": "2016-01-02",
        "average_price": 1154
    }
]

We can use code or parent_slug

curl -X GET http://127.0.0.1/v1/rates/2016-01-01/2016-01-04/CNGGZ/north_europe_sub/

Response:

[
    {
        "day": "2016-01-01",
        "average_price": 1532
    },
    {
        "day": "2016-01-02",
        "average_price": 1532
    },
    {
        "day": "2016-01-03",
        "average_price": 1532
    },
    {
        "day": "2016-01-04",
        "average_price": 1531
    }
]

METHOD POST - insert prices into db

If we want to updated our DB with prices:

curl -X POST http://127.0.0.1/v1/rates/2017-01-01/2017-02-03/CNGGZ/EETLL/123/

Response:

{
  "Ok": "Ok"
}

Keep in mind we can not use parent_slug as in METHOD GET.

ERROR response

Error handling was done proper way. Each know error would be printed in json. If happen that code crash - it would report HTTP 500 (server side issue)

How we connect to DB and why to wait X seconds ?

I did not use circuitbreakers and backoff python library. Usually it is rl good practice to use if we have DB.

rosselsprung's People

Watchers

 avatar  avatar  avatar

rosselsprung's Issues

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.