-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from traveltime-dev/feature/proto
Feature/proto
- Loading branch information
Showing
19 changed files
with
603 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
eval_gemfile '../Gemfile' | ||
|
||
gem 'google-protobuf', '~> 3.21', '>= 3.21.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'faraday' | ||
require 'base64' | ||
|
||
module TravelTime | ||
module Middleware | ||
# The Proto middleware is responsible for setting the basic auth headers for proto requests | ||
# on each request. These are automatically taken from the `TravelTime.config`. | ||
class ProtoMiddleware < Faraday::Middleware | ||
def on_request(env) | ||
env.request_headers['Authorization'] = | ||
"Basic #{Base64.encode64("#{TravelTime.config.application_id}:#{TravelTime.config.api_key}")}" | ||
env.request_headers['Content-Type'] = 'application/octet-stream' | ||
env.request_headers['Accept'] = 'application/octet-stream' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
syntax = "proto3"; | ||
|
||
package com.igeolise.traveltime.rabbitmq.requests; | ||
|
||
message Coords { | ||
float lat = 1; | ||
float lng = 2; | ||
} | ||
|
||
message Transportation { | ||
TransportationType type = 1; | ||
} | ||
|
||
enum TransportationType { | ||
// Considers all paths found by the following steps: | ||
// * up to 30 minutes of walking (always included even if no stops found) | ||
// * all connections in the 30 minute walking range from public transport | ||
// stops to other public transport stops in travel_time_limit, AND | ||
// * up to 30 minutes of walking from public transport stops that were visited | ||
// by public transport (IOW a path | ||
// [origin]--walking->[stop]--walking-->[destination] is not possible but | ||
// [origin]--walking->[stop]--public_transport-->[stop]--walking--> is. | ||
PUBLIC_TRANSPORT = 0; | ||
// Considers all paths found traveling by car from origin(s) to | ||
// destination(s) within the travel_time_limit | ||
DRIVING = 1; | ||
// Considers all paths found by the following steps: | ||
// * up to 30 minutes of driving (always included even no stops found) | ||
// * all connections in the 30 minute driving range from public transport stops | ||
// to other public transport stops in travel_time_limit, AND | ||
// * up to 30 minutes of walking from public transport stops that were visited | ||
// by public transport (IOW a path | ||
// [origin]--driving->[stop]--walking-->[destination] is not possible but | ||
// [origin]--driving->[stop]--public_transport-->[stop]--walking--> is. | ||
// AND/OR | ||
// * up to 30 minutes of walking | ||
// | ||
DRIVING_AND_PUBLIC_TRANSPORT = 2; | ||
// Considers all paths found travelling by car from origin(s) to | ||
// destination(s) including all paths that are traversable by ferries that | ||
// take cars within the travel_time_limit. | ||
DRIVING_AND_FERRY = 3; | ||
// Considers all paths found travelling by foot from origin(s) to | ||
// destination(s) within the travel_time_limit | ||
WALKING = 4; | ||
// Considers all paths found travelling by foot from origin(s) to | ||
// destination(s) including all paths that are traversable by ferries that | ||
// take passengers within the travel_time_limit | ||
WALKING_AND_FERRY = 7; | ||
// Considers all paths found travelling by bike from origin(s) to | ||
// destination(s) within the travel_time_limit | ||
CYCLING = 5; | ||
// Considers all paths found travelling by bike from origin(s) to | ||
// destination(s) including all paths that are traversable by ferries that | ||
// take bikes within the travel_time_limit | ||
CYCLING_AND_FERRY = 6; | ||
} | ||
|
||
enum TimePeriod { | ||
WEEKDAY_MORNING = 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
syntax = "proto3"; | ||
|
||
package com.igeolise.traveltime.rabbitmq.requests; | ||
|
||
import "RequestsCommon.proto"; | ||
|
||
message TimeFilterFastRequest { | ||
enum Property { | ||
FARES = 0; | ||
DISTANCES = 1; | ||
} | ||
message OneToMany { | ||
Coords departureLocation = 1; | ||
/* | ||
* We encode arrival locations as deltas (relative to the source) using a fixedpoint encoding i.e | ||
* deltaLat = round((lat - sourceLat) * 10^5).toInt | ||
* deltaLon = round((lon - sourceLon) * 10^5).toInt | ||
* | ||
* The deltas should be interleaved in the `locationDeltas` field i.e | ||
* | ||
* locationDeltas[0] should be the first lat | ||
* locationDeltas[1] should be the first lon | ||
* locationDeltas[2] should be the second lat | ||
* ... | ||
* etc | ||
*/ | ||
repeated sint32 locationDeltas = 2; | ||
Transportation transportation = 3; | ||
TimePeriod arrivalTimePeriod = 4; | ||
sint32 travelTime = 5; | ||
repeated Property properties = 6; | ||
} | ||
|
||
OneToMany oneToManyRequest = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
syntax = "proto3"; | ||
|
||
package com.igeolise.traveltime.rabbitmq.responses; | ||
|
||
message TimeFilterFastResponse { | ||
message Properties { | ||
repeated sint32 travelTimes = 1; | ||
repeated int32 monthlyFares = 2; | ||
repeated int32 distances = 3; | ||
} | ||
|
||
message Error { | ||
ErrorType type = 1; | ||
} | ||
|
||
enum ErrorType { | ||
/* | ||
* Catch all unknown error type | ||
*/ | ||
UNKNOWN = 0; | ||
/* | ||
* oneToManyRequest to many field must not be null | ||
*/ | ||
ONE_TO_MANY_MUST_NOT_BE_NULL = 1; | ||
/* | ||
* Source (either departure or arrival location) must not be null | ||
*/ | ||
SOURCE_MUST_NOT_BE_NULL = 2; | ||
/* | ||
* Transportation mode must not be null. | ||
*/ | ||
TRANSPORTATION_MUST_NOT_BE_NULL = 3; | ||
/* | ||
* Source (either departure or arrival location) must not be null | ||
*/ | ||
SOURCE_NOT_IN_GEOMETRY = 4; | ||
|
||
/* | ||
* Transportation mode unrecognized. | ||
*/ | ||
UNRECOGNIZED_TRANSPORTATION_MODE = 5; | ||
|
||
/* | ||
* The travel time limit is too low to process this request. | ||
*/ | ||
TRAVEL_TIME_LIMIT_TOO_LOW = 6; | ||
|
||
/* | ||
* The travel time limit is too high to process this request. | ||
*/ | ||
TRAVEL_TIME_LIMIT_TOO_HIGH = 7; | ||
|
||
/* | ||
* User id not set. | ||
*/ | ||
AUTH_ERROR_NO_USER_ID = 8; | ||
|
||
/* | ||
* Message sent to wrong queue - transportation mode cannot be handled. | ||
*/ | ||
SERVICE_MISMATCH_WRONG_TRANSPORTATION_MODE = 9; | ||
|
||
/* | ||
* Source is in a area that doesn't have any points that can be out of | ||
* search e.g a lake, mountains or other desolate areas. | ||
*/ | ||
SOURCE_OUT_OF_REACH = 10; | ||
|
||
/* | ||
* The interleaved deltas array should have (lat/lon) deltas and have an | ||
* even number of elements | ||
*/ | ||
INTERLEAVED_DELTAS_INVALID_COORDINATE_PAIRS = 11; | ||
|
||
/* | ||
* Public transport requests do not support returning distances for | ||
* returned points. | ||
*/ | ||
DISTANCE_PROPERTY_NOT_SUPPORTED = 12; | ||
} | ||
|
||
Error error = 1; | ||
Properties properties = 2; | ||
} |
Oops, something went wrong.