The FE service is organized into:
- Server definition and startup logic: defined in main.go and startup.go
- Services: handle http requests; are under folder service
- Domain logic: contains generic domain logic under different folders with topic name
Server Startup
The main.go file does the following:
- Initializes server and kicks-off on a configured port
- Reads configurations
- Initializes GRPC clients to be used by all services
- Initializes services that handle http requests
- Startsup asynchronous service, which runs the background
- Defines common handlers that:
- set/read headers regarding CORS, versioning, supported headers, etc
- authenticate users with/without admin permissions
- add context information to each http request, including the request-id and the logger
- handle panics by converting them to http 500 errors
- Defines endpoints and respective handlers
The startup.go file does the following:
- Resets semantic analyses whenever we do a semantic version bump - used to restart semantic analyses when we make changes to the logic that may change the output of such analyses
- For all stored repos, restarts iterated operations, e.g., it resumes code review import and repo symbols if required
Services
Usually, services are organized into a main service.go file, which defines the service struct and the handlers, and some additional helper files that usually contain the FE entities and functions for converting to/from GRPC entities. We now describe each service in turn.
Admin: