Sync Sandbox
Sync Sandbox is a gRPC & RESTful HTTP API which I use to try out various project ideas.
Quickstart
Run the following command to build & spin up our docker container:
sh start.sh --build
Note: currently you would be required to build the image locally, in the future I plan to add an ECR repo with terraform that will automatically push images in a Jenkins pipeline fashion.
gRPC Gateway
The gRPC gateway translates a RESTful HTTP API into gRPC. Sync-sanbox accepts both gRPC and REST calls, which means you can easily perform the following to receive a response:
# start the API
sh start.sh
# curl our test endpoint
curl http://localhost:8080/test?name=echo
# response
{"name":"echo"}
This is just a placeholder for now, but will hold interesting info in the future.
Update: added an additional sandbox endpoint to view consolidated metadata about your spotify playlist:
# start the API
sh start.sh
# curl our test endpoint
curl http://localhost:8080/spotify/playlist/tracks
# response
{"tracks":[{"name":"Remedy","artists":[{"name":"Ferreck Dawn"},{"name":"Shyam P"}]},{"name":"Take Me Away","artists":[{"name":"Dombresky"},{"name":"Wh0"}]}]}
Compiling Protocol Buffers
Protocol buffers can be found in the proto/
directory, and contain definitions for gRPC calls.
Each field should contain detailed documentation for future feature work.
Any changes to *.proto
files will require re-compilation -- luckily this can easily be done by running:
sh start.sh --compile
Mocks & Testing
Inevitably mocks will be required when testing. To add a new mock, ensure your interface is structured in a way that will allow unit tests to run successfully.
This requires your interface to contain any functions that would contact an external resource, such as an API.
Once completed, update start.sh
with your mock source, destination, and package, then execute the following command:
sh start.sh --mocks
Your new mock files should be found in the destination, and can now be used in unit tests.
Postman Tests
Postman integration tests are documented and found here.
gRPC Client
Client code can be found here and can easily run with the following command:
sh start.sh --client
The client container will perform various gRPC test calls such as: unary, server-streaming, client-streaming, and bidirectional-streaming.
TODO
- Automate tests (Cloud-based CI)
- Swagger docs
- Setup sync logic
- Metrics