Trying to write a TODO app with micro services architecture. I am using several technologies just for the sake of using them and getting first-hand experience with them.
-
Install go-1.9
-
Install Docker
-
Install
dep
- dep -
Install dependencies by running
dep ensure
-
Run
docker build -t micro-todo .
to build Docker image -
Start Docker container from built image
By default, container runs
Registry
service. To specify which service to run, append<service name>.bin
to the container running command. E.g.docker run -d -p 127.0.0.1:30010:3000 -p 127.0.0.1:8080:80 micro-todo auth.bin
To start admin web application, go to
admin/README.md
for instructions
admin
-Admin
web application for exploring services stateauth
-Auth
servicelogger
-Logger
serviceproto
- shared service RPC protocol and generated API gatewaysregistry
-Registry
servicetodo
-TODO
servicevendor
- project dependencies
Registry
- public - list of all available services and load balancingAuth
- internal - authorizes and registers usersTODO
- internal - keeps TODO tasksAdmin
- admin - provides WEB UI for logs and status of all servicesLogger
- internal - receives logs from all services and provides them toAdmin
For information about service API and configuration see following files:
- Services register themselves in
Registry
- Client performs request to the
Registry
to specific service and its API endpoint Registry
proxies request to the best instance, converting request to internal protocol, and waits for response- On receiving response,
Registry
converts response from internal protocol to HTTP response and sends back to client
- Service queries
Registry
forLogger
service - Service sends log message to
Logger
service
Admin
queriesRegistry
forLogger
serviceAdmin
queriesLogger
service for requested service type logsAdmin
updates log everyn
secondsAdmin
queriesRegistry
for services status
Registry
:- Works on gRPC
- Works on HTTP
- Keeps up-to-date list by performing service instance health checks
- Supports server-side registering
- Responses with service types list
- Responses with service type instances list
- Responses with address of suitable requested service (balancing)
- Supports several load balancing algorithms:
- Random balancer
- Round-robin balancer
- Weighted random balancer
- Weighted round-robin balancer
- Has health HTTP endpoint
- Has health RPC method
- Responses with error message if service is unavailable
- Restricts querying internal services from external clients
- Restricts querying admin services from external clients
- Writes logs to
Logger
Auth
:- Registers new users
- Authorizes users
- Provides auth tokens for authorized users
- Authenticates users by their auth tokens
TODO
:- Stores TODO tasks
- Stores TODO lists of user
- Allows adding TODO tasks
- Allows editing TODO tasks
- Allows deleting TODO tasks
- Allows sharing TODO tasks with different users
- Writes logs to
Logger
Admin
:- Authenticates admin in WEB UI
- Collects logs from
Logger
- Shows health status of all services
- Periodically updates status and logs
Logger
:- Receives logs from different services
- Stores them by service type instances
- Responses with logs of specific service type instance
- Persists logs on disks