Skip to content

This project implements a WebSocket server designed for real-time communication, suitable for applications requiring instant messaging, live updates, or any scenario demanding low-latency data exchange between clients and server.

License

Notifications You must be signed in to change notification settings

zlz3907/go-postoffice

Repository files navigation

GO-POSTOFFICE

中文版

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.

Go-Postoffice Communication Structure

Table of Contents

  1. Features
  2. Installation
  3. Quick Start
  4. Configuration
  5. API Documentation
  6. Message Protocol
  7. Client Examples
  8. Contributing
  9. License

Features

  1. High-performance Concurrent Processing: Utilizes Go's goroutines and channels for efficient concurrent connection management.
  2. Flexible Message Routing: Based on the post office model, supports point-to-point and broadcast message distribution for efficient message delivery.
  3. Security Authentication: Integrates token authentication to ensure connection security.
  4. Configurable Message Validation: Supports optional JSON Schema validation to ensure message format correctness.
  5. Environmental Adaptability: Supports multi-environment configuration for easy deployment in different scenarios.
  6. Graceful Service Management: Implements graceful startup and shutdown mechanisms to ensure service stability.
  7. Scalability: Modular design for easy feature expansion and customization.
  8. Real-time Communication: Full-duplex communication based on WebSocket, supporting real-time data exchange.

Advantages of the Post Office Model

  • 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.

Quick Start Guide for Enterprise AI Chatbot Integration

For a detailed guide on how to quickly integrate an enterprise-level AI chatbot, please refer to our Enterprise AI Chatbot Integration Guide.

Installation

Ensure that Go (version 1.23.1 or higher) is installed on your system.

  1. Clone the repository:

    git clone https://github.com/zlz3907/go-postoffice.git
    
  2. Enter the project directory:

    cd go-postoffice
    
  3. Install dependencies:

    go mod tidy
    

Quick Start

  1. Configure the environment: Copy .env/config-dev.json to .env/config-zhycit.json and modify the configuration as needed.

  2. Run the server:

    go run main.go
    
  3. 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.

  4. Run the built executable:

    For Linux/macOS:

    ./dist/go-postoffice-linux   # or go-postoffice-macos
    

    For Windows:

    .\dist\go-postoffice-windows.exe
    

Configuration

Main configuration items include:

  • socketPort: WebSocket server port
  • maxWebSocketConnections: Maximum number of connections
  • dataSource: Data source configuration (e.g., Redis)

For detailed configuration instructions, please refer to the Configuration Documentation.

API Documentation

For API usage instructions, please refer to the API Documentation.

Message Protocol

For message format and field descriptions, please refer to the Message Protocol Documentation.

Client Examples

Contributing

We welcome contributions of any form. Please read the Contributing Guidelines to learn how to participate in project development.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

About

This project implements a WebSocket server designed for real-time communication, suitable for applications requiring instant messaging, live updates, or any scenario demanding low-latency data exchange between clients and server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages