Skip to content

vbcherepanov/flight-calculator

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flights Test Assignment

Prerequisites:

Run the service

make start

Run tests

make test

Benchmark

$ make bench
goos: darwin
goarch: arm64
pkg: flights-test/internal/services/calculator
BenchmarkCalculator_Calculate
BenchmarkCalculator_Calculate-10    	       9	 118881315 ns/op
PASS
ok      flights-test/internal/services/calculator       2.948s

API Documentation

POST /calculate

Request: array of flights. Each flight is an array with the departure and arrival airports

The max possible number of flights is about 1051200. When someone who born in some airport travels every day for the whole 120-years life without any breaks. And it's avg flight takes 30 minutes and 30 minutes waiting in airport (1 hour per flight in total)

[
  [ "SFO", "ATL" ],
  [ "ATL", "GSO" ],
  [ "GSO", "IND" ],
  [ "IND", "EWR" ]
]

Response:

200 OK

[ "SFO", "EWR" ]
400 Bad Request

{ "error": "incorrect path" }

Example:

curl -X POST --location "http://localhost:8080/calculate" \
    -H "Content-Type: application/json" \
    -d "[
          [ \"SFO\", \"ATL\" ],
          [ \"ATL\", \"GSO\" ],
          [ \"GSO\", \"IND\" ],
          [ \"IND\", \"EWR\" ]
        ]"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 91.8%
  • Makefile 4.2%
  • Dockerfile 4.0%