Timer API Server is a demo Golang project that implements RESTful APIs and gRPC APIs for Timer.
Major Tech stacks: Golang, Gin, gRPC, MariaDB, GORM, Cobra, Pflag, Viper, Docker, GNU Make
- Check prerequisites
- Docker
- Docker Compose (NOTE: we are using
docker-compose
instead ofdocker compose
to be compatible with Linux) - GNU make
-
Check out the repository to your local machine and go to the project root directory.
git clone [email protected]:josephzxy/timer_apiserver.git cd timer_apiserver
-
Build & launch with
docker-compose
make docker.compose.up
-
Try out RESTful APIs & gRPC APIs
# Create a timer named "hello" make demo.rest.post.hello # Display current content in the table make demo.db.show # Get the timer named "hello" make demo.rest.get.hello # Get all timers make demo.rest.get.all # Update the timer named "hello" to a new name "hello_again" make demo.rest.put.hello DEMO_REST_PUT_NAME=hello_again # Get all pending timers # Timers are pending if they are not deleted and not triggered yet make demo.grpc.getallpending # Delete the timer named "hello_again" make demo.rest.delete.hello_again
Timer API Server is a demo Golang project that implements RESTful APIs and gRPC APIs for Timer.
- Loose-coupling design where high-level pluggable controllers(e.g. REST API Server) share layered low-level resource managing service(e.g. MySQL middleware).
- Aligned with 12-factor-app methodology with supports for taking configurations from various sources, treating logs as event streams, launching the app as stateless processes, etc.
- Achieved 95% test coverage on CodeCov and A+ on Go Report Card. Leverages GNU Make to automate trivial tasks. Lints, tests, and builds on each commit with CircleCI. Adapted Angular-style Git commit message and Gitflow workflow.
- Enabled automated building and serving with Docker Compose.
- Enabled auto-generation of RESTful API Swagger documentation.
-
RESTful API
View swagger doc as a webpage by
make swagger
Or check out swagger.yml directly.
-
gRPC API
Please check out timer.proto.