GBM Challenge Database Server
A microservice that stores Ride and Location information through an API and
publishes Location information to RabbitMQ.
The counterpart for this service that must be run in conjunction with this one
to get a fully functioning setup can be found
here.
Features
- Ride CRUD
- Location CRUD
- Location publishing to RabbitMQ
Requirements
- Docker 18.06.1-ce+
- go1.11.2+
- bash
- curl
- watch
Usage
Go get the repository
go get bitbucket.org/jrlangford/gbm-challenge-dbserver
Build the binary
cd $GOPATH/bitbucket.org/jrlangford/gbm-challenge-dbserver
go get
go build
Run the system
Helper scripts are provided to run subsystems and execute commands in a default
configuration
Launch the backend database
./scripts/launchdb.sh
Launch the message broker
./scripts/launchrmq.sh
You can access tue message broker's interface in the following address:
http://localhost:15672
with username guest
and password guest
Run the server
./gbm-challenge-dbserver
This will launch the server listening, by default, on 'localhost:8080'
Post a ride
./scripts/postRide.sh <rideTag>
Post locations
watch ./scripts/postLocation.sh <rideID>
This will continuously post the same location to the server
API
Ride
Response fields:
id
: record id
tag
: ride tag
created_at
: date of record creation
updated_at
: date of last modification
GET list
URI: /api/v0/ride
Returns the list of stored rides
Example:
curl localhost:8080/api/v0/ride
GET item
URI: /api/v0/ride/
Returns the list of stored rides
Example:
curl localhost:8080/api/v0/ride/1
POST
URI: /api/v0/ride
Creates a new Ride. Returns the newly created record.
Data fields:
Example:
curl localhost:8080/api/v0/ride --data '{"tag":"rideone"}'
PATCH
URI: /api/v0/ride/
Updates a field from a Ride. Returns the updated record.
Data fields:
DELETE
URI: /api/v0/ride/
Marks the selected record as deleted without actually removing it from the
database
Location
Response fields:
id
: record id
ride_id
: id of the related ride
latitude
: recorded latitude
longitude
: recorded longitude
created_at
: date of record creation
updated_at
: date of last modification
GET List
URI: /api/v0/location
Returns the list of stored locations
Filters:
ride_id
: Filters list by related ride id
ride_tag
: Filters list by related ride tag
Example:
curl localhost:8080/api/v0/location?ride_tag=rideone
GET Item
URI: /api/v0/location/
Returns the list of stored locations
Example:
curl localhost:8080/api/v0/location/<id>
POST
URI: /api/v0/location
Creates a new Location. Returns the newly created record.
Data fields:
ride_id
: id of the related ride
latitude
: recorded latitude
longitude
: recorded longitude
Example:
curl localhost:8080/api/v0/location \
--data '{"ride_id":1, "latitude":"9.984321", "longitude":"10.234123"}'
PATCH
URI: /api/v0/location/
Updates a field from a Location. Returns the updated record.
Data fields:
ride_id
: id of the related ride
latitude
: recorded latitude
longitude
: recorded longitude
DELETE
URI: /api/v0/location/
Marks the selected record as deleted without actually removing it from the
database
Potential improvements
- User authentication via oauth
- Generation of single exchange per user
- Extensive input validation
- HTTP header setting and validation
- Dependency management
- Extensive testing