BinaryGame Users Microservice

The users service is a microservice responsible for managing user-related operations in the distributed game. It handles user registration.
Table of Contents
Features
- User creation
- User editing
Requirements
- Go 1.22+
- Valkey (an open-source distribution of Redis)
Installation
-
Clone the repository:
git clone https://gitlab.com/binarygame/microservices/users.git
cd users
-
Install the dependencies:
go mod tidy
Configuration
Configure the service by setting the following environment variables:
USERS_SERVICE_HOST: The host for the users service. Default: 0.0.0.0.
USERS_SERVICE_PORT: The port for the users service. Default: 8000.
VALKEY_SERVICE_HOST: The host for the Valkey service. Default: localhost.
VALKEY_SERVICE_PORT: The port for the Valkey service. Default: 6379.
LOG_LEVEL: The logging level for the service. Default: DEBUG.
OTEL_COLLECTOR_HOST (optional): The host for the OpenTelemetry collector.
OTEL_COLLECTOR_PORT (optional): The port for the OpenTelemetry collector.
You can set these variables in a .env file or export them directly in your shell.
Usage
-
Run the development server:
go run cmd/users/main.go
-
The service will be available at http://localhost:8000.
Calling the API with grpcurl
You can use grpcurl to call the service. For example, to create a user:
grpcurl -plaintext -d '{"nickname": "mycoolnick", "emoji": "👀"}' localhost:8000 connectrpc.users.v1.UsersService.AddUser
Building Image Builds Locally
This project makes use of Earthly to build container images and for local testing binaries.
Build project with binary output at build/app:
earthly +build
Build project with images as output:
# This command outputs the image names for your testing
earthly +build-image
Deploy
On this project, Earthly is used to build and publish the images on Gitlab's built-in Container Registry.
The following tags are available from this system:
latest tags:
latest: latest production build (alias: latest-production)
latest-staging: latest staging build
latest-development: latest development build (git version)
latest-mr-<Merge Request ID>: latest build from a specific merge request.
- The merge request id is the internal variant.
Commit-specific tags:
<Short Commit Hash>-production: Available for all commits in the production branch.
<Short Commit Hash>-staging: Available for all commits in the staging branch.
<Short Commit Hash>-development: Available for all commits in the development branch.
Testing
To run the tests, use the following command:
go test ./...
Alternatively, you can use gotestsum to run the tests with summarized output:
go run gotest.tools/gotestsum@latest
Ensure you have the test dependencies installed.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name.
- Make your changes and commit them:
git commit -m 'Add some feature'.
- Push to the branch:
git push origin feature/your-feature-name.
- Open a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Credits
- Project icon designed by
Good Ware from Flaticon.