This project is a Go-based microservice that integrates Kafka messaging and WebSocket support. It provides an infrastructure for real-time data processing, message broadcasting, and external exchange interactions.
- Microservice Architecture: Modular design with clear separation of concerns.
- Dependency Injection with Wire: Uses Google Wire for dependency injection, improving modularity and testability.
- Kafka Integration: Supports message production and consumption.
- WebSocket Support: Connects to external WebSocket services (e.g., Binance API).
- Automatic Configuration Reload: Monitors changes in configuration files and applies updates without restarting the service.
- Dockerized Deployment: Comes with Docker and Docker Compose support for easy deployment.
.
├── config.json
├── docker-compose.yml
├── Dockerfile
├── go.mod
├── go.sum
├── main.go
├── README.md
├── internal/
│ ├── app/
│ │ ├── wire.go
│ │ ├── wire_gen.go
│ ├── common/
│ │ ├── log.go
│ ├── config/
│ │ ├── checker.go
│ │ ├── config.go
│ ├── infrastructure/
│ │ ├── message_buss/
│ │ │ ├── kafka_consumer.go
│ │ │ ├── kafka_producer.go
│ │ ├── web_sockets/
│ │ ├── binance_service.go
│ ├── models/
│ │ ├── config.go
│ ├── services/
│ │ ├── broadcast.go
│ │ ├── interfaces/
│ │ ├── broad_cast.go
│ │ ├── consumer.go
│ │ ├── exchange_service.go
│ │ ├── producer.go
- Go 1.XX+
- Docker & Docker Compose
- Kafka
- Clone the repository:
git clone <repository-url> cd crypto-price-broadcast
- Install dependencies:
go mod tidy
- Generate dependency injection with Wire:
wire
- Start Kafka (if not running):
docker-compose up -d
- Run the service:
go run main.go
Modify config.json
to update Kafka settings, WebSocket endpoints, and other parameters.
The service supports automatic reloading of configuration files. When config.json
is updated, the changes are applied dynamically without requiring a restart. This feature ensures seamless updates and minimizes downtime.
The project uses Google Wire for dependency injection. Wire helps in managing dependencies efficiently and improves the modularity and testability of the application. To regenerate dependency injection code, run:
wire
To build and run the service in Docker:
docker build -t crypto-price-broadcast .
docker run -d --name crypto-price-broadcast crypto-price-broadcast
Or use Docker Compose:
docker-compose up -d
- Scalability: The microservice architecture allows easy scaling of individual components.
- Modularity: Well-structured codebase ensures better maintainability and extensibility.
- Real-time Processing: Kafka and WebSocket integration enable efficient real-time message handling.
- Ease of Deployment: Dockerized setup simplifies deployment across different environments.
- Automatic Configuration Updates: Reduces downtime by dynamically reloading configuration changes.
- Improved Testability: Dependency injection with Wire enhances testability by decoupling components.
MIT License. See LICENSE
file for details.