goproxy is an HTTP(S)-proxy server.
It has a microservice architecture, with each microservice running in a separate container. Microservices use a Kafka bus to transmit events to one another.
Check the docker-compose.yml file in the project's root directory
The core service, used as an HTTP-proxy server.
The proxy uses an auth database to authorize clients to access the proxy service. Only existing users can use the proxy.
Consumes:
UserExceededTrafficLimitEvent- triggers user restrictions;UserConsumedTrafficWithoutPlan- triggers user restrictions.
Produces:
UserConsumedTrafficEvent
Used to get, create, update, and delete users
Consumes UserConsumedTrafficEvent, which is produced by proxy when a user has used it.
Consumes:
UserConsumedTrafficEvent- triggers updates to user traffic stats and validates user plans.
Produces:
UserExceededTrafficLimitEvent- triggers user restrictions;UserConsumedTrafficWithoutPlan- triggers user restrictions.
There are 3 separate databases:
- postgres - used for user authentication;
- plan-postgres - used to store plans and user-plan affiliations.
The migration process is handled by migrator.go, located in the Data Access Layer (DAL). All migration files are placed in directories with the same name as the corresponding database.
For example:
- Proxy database migrations are stored in the proxydb directory;
- Plan database migrations are stored in the plans directory.