GO-POSTOFFICE is a high-performance WebSocket server implementation based on Go, designed using the post office concept model. This project primarily handles connection management, security authentication, and message (mail) distribution and delivery.
- Features
- Installation
- Quick Start
- Configuration
- API Documentation
- Message Protocol
- Client Examples
- Contributing
- License
- High-performance Concurrent Processing: Utilizes Go's goroutines and channels for efficient concurrent connection management.
- Flexible Message Routing: Based on the post office model, supports point-to-point and broadcast message distribution for efficient message delivery.
- Security Authentication: Integrates token authentication to ensure connection security.
- Configurable Message Validation: Supports optional JSON Schema validation to ensure message format correctness.
- Environmental Adaptability: Supports multi-environment configuration for easy deployment in different scenarios.
- Graceful Service Management: Implements graceful startup and shutdown mechanisms to ensure service stability.
- Scalability: Modular design for easy feature expansion and customization.
- Real-time Communication: Full-duplex communication based on WebSocket, supporting real-time data exchange.
- Decoupling: Complete separation of senders and receivers, increasing system flexibility.
- Reliability: Message persistence and retry mechanisms ensure reliable message delivery.
- Extensibility: Easy to add new message types and processing logic.
- Load Balancing: Multiple "post office" instances can be implemented to increase system throughput.
For a detailed guide on how to quickly integrate an enterprise-level AI chatbot, please refer to our Enterprise AI Chatbot Integration Guide.
Ensure that Go (version 1.23.1 or higher) is installed on your system.
-
Clone the repository:
git clone https://github.com/zlz3907/go-postoffice.git
-
Enter the project directory:
cd go-postoffice
-
Install dependencies:
go mod tidy
-
Configure the environment: Copy
.env/config-dev.json
to.env/config-zhycit.json
and modify the configuration as needed. -
Run the server:
go run main.go
-
Build the executable:
For Linux:
env GOOS=linux GOARCH=amd64 go build -ldflags "-X main.env=zhycit" -o dist/go-postoffice-linux
For macOS:
env GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.env=zhycit" -o dist/go-postoffice-macos
For Windows:
env GOOS=windows GOARCH=amd64 go build -ldflags "-X main.env=zhycit" -o dist/go-postoffice-windows.exe
Note: Replace
zhycit
with your desired environment name if different. -
Run the built executable:
For Linux/macOS:
./dist/go-postoffice-linux # or go-postoffice-macos
For Windows:
.\dist\go-postoffice-windows.exe
Main configuration items include:
socketPort
: WebSocket server portmaxWebSocketConnections
: Maximum number of connectionsdataSource
: Data source configuration (e.g., Redis)
For detailed configuration instructions, please refer to the Configuration Documentation.
For API usage instructions, please refer to the API Documentation.
For message format and field descriptions, please refer to the Message Protocol Documentation.
We welcome contributions of any form. Please read the Contributing Guidelines to learn how to participate in project development.
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.