Giter VIP home page Giter VIP logo

transportscheduler's Introduction

TS

Build Status Coverage Status Code Climate

TransportScheduler application dependencies:
GenStateMachine for station FSM and GenServer for IPC.
Maru for RESTful API implementation.
Edeliver using Distillery for building releases and deployment.

Other packages used:
ExCoveralls for test coverage.
ExProf for profiling.
Credo for code quality.

Usage

Setup

Run the following commands to compile:

cd TransportScheduler
mix deps.get
mix compile
mix test

Run the following command to build a release, and copy data directory into build path:

mix release
cp -r data/ _build/dev/rel/ts

Run the following command to run the application interactively:

_build/dev/rel/ts/bin/ts console

Issue the following cURL command (in a separate terminal) for initialisation of the network:

curl http://localhost:8880/api

Other cURL commands to query the network (as mentioned in 'Testing') can now be issued.

To stop the Erlang runtime and exit the TS console:

System.halt

Testing

For testing the API, following cURL commands are issued to:

  1. Obtain Schedule of a Station:
curl -X GET 'http://localhost:8880/api/station/schedule?station_code=%STATION_CODE%&date=%DATE%'

where %STATION_CODE% is a positive integer indicating the station code of the source and %DATE% is the date of travel in the format 'dd-mm-yyyy'.

  1. Obtain State of a Station:
curl -X GET 'http://localhost:8880/api/station/state?station_code=%STATION_CODE%'

where %STATION_CODE% is a positive integer indicating the required station code.

  1. Obtain Travel Itinerary:
curl -X GET 'http://localhost:8880/api/search?source=%SOURCE%&destination=%DESTINATION%&start_time=%START_TIME%&end_time=%END_TIME%&date=%DATE%'

where %SOURCE% and %DESTINATION% are positive integers indicating the station codes of the source and destination respectively, %START_TIME% and %END_TIME% are non-negative integers indicating start and end times of the itinerary in seconds from 12 am, and %DATE% is the date of travel in the format 'dd-mm-yyyy'.

Deployment

Run the following commands to deploy (currently server and user are localhost): UNTESTED

mix edeliver build release
mix edeliver deploy release

Run the following command to start application: UNTESTED

mix edeliver start
cp -r data/ /home/$USER/test/ts

Benchmark Tests

For running the respective benchmarks (async/synchronous), use

mix sync_benchmark
mix async_benchmark

A shell script for running the synchronous benchmark multiple times is:

for i in $(seq 1 $n); do mix benchmark [2>/dev/null | grep -C 2 "^Start time: "]; done [> ~/file.out]

where $n is the number of random queries over which the benchmark must be run. file.out is the file that will store the log thus generated by the benchmark. The portion of the command in [square brackets] is optional.

Automatically, three files async_test.csv, sync_test.csv and times.csv are created in the data/ directory.

transportscheduler's People

Contributors

ahaldar avatar prasadtalasila avatar suhasspai 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.