Giter VIP home page Giter VIP logo

comet's Introduction

Gopusher Comet

Gopusher Comet 是一个支持分布式部署的通用长连接接入层服务,接管客户端连接。Gopusher Comet is a access layer service that handling all client persistent connections with distributed cluster deployment.

你可以很容易的使用 http api 来构建实时聊天,通知推送应用。You can use http api to develop a instant messaging application or a push notification application easily.

demo: https://chat.yadou.net

这是一个用php开发的聊天应用(源码),采用comet作为长连接接入层,采用php开发聊天的路由和逻辑层部分。

This is a chat application developed in php (code souce), using comet service to handle all client persistent connections, and using php language develop the chat routing and logical layer.

开发指南 Develop Guide

  • wiki
  • QQ交流群: 818628641

特性

  • 简单通用
  • 多协议支持,websocket 已经支持,tcp 在开发中
  • 集群支持
  • 开发者友好,采用http api的方式进行rpc调用,便于不同语言的接入开发(你不需要学习golang,只需要运行comet。)
  • 支持docker方式运行 (docker 运行)

Features

  • light weight
  • multi-protocol support, websocket is already supported, tcp is coming soon
  • cluster support
  • developer friendly, rpc call using http api to make develop with any program languages easily( You don't need to learn golang, just run comet. )
  • Support running with docker (running with docker)

安装 Installation

Installing Go

https://golang.org/doc/install

下载 Download

下载项目源码。download comet souce code.

依赖 Dependencies

go get github.com/coreos/etcd/clientv3
go get github.com/gorilla/websocket
go get github.com/fatih/color
go get gopkg.in/ini.v1

编译 Build

go build -o comet main.go

mac上编译debian版本, build debian bin on mac

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o comet main.go

运行 Run

运行etcd Run etcd

run with docker

当然你可以选择你喜欢的方式运行etcd. Of course you can run etcd as the way you like.

配置 Configuration

Edit comet.ini

# 最大的cpu执行数
max_proc=1
# etcd 中 comet service name
comet_service_name=comet
# etcd server addr
etcd_addr=127.0.0.1:2379
# api addr
rpc_api_url=http://www.chat.com/im/index/rpc
rpc_user_agent="CtxImRpc 1.0"

# 通信协议 协议,可选项 tcp(tcp需要后续开发), ws, wss (如果为 wss 需要设置 wss_cert_pem 和 wss_key_pem)
socket_protocol=ws
# websockeet 监听端口
websocket_port=8900
# wss_cert_pem=
# wss_key_pem=
# comet rpc 配置
comet_rpc_addr=192.168.3.165
comet_rpc_port=8901
comet_rpc_token=token

运行 Run

  1. Run comet monitor
./comet -c comet.ini -m
  1. Run comet
./comet -c comet.ini

到现在为止,你已经可以使用comet了,并采用你喜欢的语言进行接入开发你的长连接应用了。So far, you can already use comet service and develop your persistent connections application with your favorite program language.

集群配置 Cluster configuration

如果你需要采用集群的方式运行,你可以采用nginx等来做负载均衡。If you need to run comet cluster, you can use nginx, etc. for load balancing.

upstream websocket {
    server 192.168.3.165:8900 weight=1;
    server 192.168.3.165:8902 weight=1;
}

server {
    listen 8910;

    server_name www.chat.com$;

    location / {
        proxy_pass http://websocket;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

你也可以采用服务器下发comet ip port的方式来进行负载均衡,you can also use the method of sending the comet ip port to load balance.

comet's People

Contributors

sh7ning avatar

Watchers

不想当厨子的老谭 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.