# websocket-cluster **Repository Path**: smebxyz/websocket-cluster ## Basic Information - **Project Name**: websocket-cluster - **Description**: 遵循订阅-发布模式的Websocket集群服务,使用golang开发,服务注册和发现使用了etcd,服务间调用使用了grpc, - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2024-01-08 - **Last Updated**: 2024-07-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: Go语言, Flutter, websocet, IM, 物联网 ## README # WebSocket-Cluster 这是一个基于websocket协议的发布-订阅模型的消息传递集群的解决方案。 - [WebSocket-Cluster](#websocket-cluster) - [Components](#components) - [Language](#language) - [ThirdPartyComponentUse](#thirdpartycomponentuse) - [Config](#config) - [项目文件介绍](#项目文件介绍) - [设计思路](#设计思路) ## Components 需要以下组件才能支持 - redis - etcd ### Language - Golang ### ThirdPartyComponentUse - [zinx](https://github.com/aceld/zinx) - [grpc](https://github.com/go-micro/go-micro) - [websocket](https://github.com/gorilla/websocket) - [go-redis](https://github.com/redis/go-redis) - [gin](https://github.com/gin-gonic/gin) - [zap](https://github.com/uber-go/zap) - [etcd](https://github.com/etcd-io/etcd) - [protobuf](https://github.com/protocolbuffers/protobuf-go) 1. zinx、websocket提供标准的websocket协议服务 2. grpc 提供集群内服务调用 3. go-redis 提供订阅记录服务和Ws端点记载服务 4. etcd 服务注册与发现 5. zap 日志记载和分级任务 6. gin 端点注册订阅、订阅管理、发布订阅等服务 ### Config ``` hosts: redis_address: 192.168.43.121:6379 redis_password: etcd_urls: 192.168.43.121:2379 ws_port: 7001 grpc_port: 8001 web_port: 8080 http2_port: 9001 ``` 1. ws_port ws端口 2. redis redis 配置文件 3. etcd_urls etcd服务群 4. grpc_port grpc服务运行端口 5. web_port web调用端口 6. grpc_client 调用端口 ### 项目文件介绍 ``` E:. ├─api 遵循swagger的 json 模板文件 ├─assets 仓库所使用的一些静态文件 ├─build 打包和持续集成 CICD 模板文件 ├─cmd 项目执行入口 ├─internal 功能代码 ├─configs 默认配置文件 ├─deployments 容器编排模板文件 ├─docs 使用文档 ├─examples 外部使用示例 ├─scripts 构建 安装 分析脚本 ├─tests 测试用力 └─web 一个简易的集群状态控制台 ``` ### 设计思路 1. 由websocket集群和web集群构成 2. websocket服务提供 消息推送和订阅注册 3. web集群提供订阅管理 消息发布 负载均衡端点选择