Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingson committed Apr 1, 2019
1 parent d6f907d commit 430142f
Showing 7 changed files with 326 additions and 39 deletions.
42 changes: 31 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -7,21 +7,44 @@ goim 是 非常成功的 IM ( 即时消息平台), 依赖项为 kafka ( 消息

由于修改比较大, 暂时用新的 repo 来进行代码管理, 以后看情况是否能回归到 Terry-Mao 的主线版本上.



同时, 与 [goim](https://github.com/Terry-Mao/goim) 有所差异的重要一点是:

**这个 fork 是实验性质, 请不要用于生产环境!! this repo is NOT production ready!!**



### Movation 动机

作为一个曾经的架构师(2005~2014, Utstarcom IPTV/OTT 事业部) 与当前自由的技术类咨询与服务从业者, 有合作伙伴询问 IM 用在视频直播中的方案, 我作了一些研究( 作为曾经的架构师/解决方案工程师/ IPTV播控产品线 release manager, 我除了技术原型的实现代码以外, 甚少参与实际撰写代码的工作 )



中国 B站( BiliBili ) 的技术领军 [毛剑](https://github.com/Terry-Mao/) 是我神交以久的技术专家, 这次就以 [goim](https://github.com/Terry-Mao/goim) 为基础进行了一些学习与扩展尝试.



同时, 另一位技术专家 [Xin.zh](https://github.com/alexstocks) 的文章 [一套高可用实时消息系统实现](https://alexstocks.github.io/html/pubsub.html) 以及我在电信/广电的经历, 这一次, 闲来无事, 尝试写一些代码来加深学习.



### 主要变更

1. 消息队列修改为 [nats](https://github.com/nats-io/gnatsd) + [liftbridge](https://github.com/liftbridge-io/liftbridge) 注: [liftbridge](https://github.com/liftbridge-io/liftbridge) 替代了 [nats-streaming-server](https://github.com/nats-io/nats-streaming-server) , 相关信息参见[liftbridge介绍文章](https://bravenewgeek.com/introducing-liftbridge-lightweight-fault-tolerant-message-streams/)
2. 日志替换为 [uber-go/zap](https://github.com/uber-go/zap), 替换原一是因为 zap 快一点, 二是个人更为熟悉这个日志库
3. 修改了三个应用程序的启动方式, 去除了所有启动参数, 改为读取指定的配置文件 ( 为将来实现 daemon 化而准备)
![arch](./docs/arch.png)


### 文件
修改文件如下
- [x] 消息队列修改为 [nats](https://github.com/nats-io/gnatsd) + [liftbridge](https://github.com/liftbridge-io/liftbridge) 注: [liftbridge](https://github.com/liftbridge-io/liftbridge) 替代了 [nats-streaming-server](https://github.com/nats-io/nats-streaming-server) , 相关信息参见[liftbridge介绍文章](https://bravenewgeek.com/introducing-liftbridge-lightweight-fault-tolerant-message-streams/)
- [x] 日志替换为 [uber-go/zap](https://github.com/uber-go/zap), 替换原一是因为 zap 快一点, 二是个人更为熟悉这个日志库
- [x] 修改了三个应用程序的启动方式, 去除了所有启动参数, 改为读取指定的 toml 配置文件( 同时, 预留接口以久将来进行读取远程配置, 及配置参数动态加载)
- [ ] 深入 comet / logic 模块尽量抽象接口, 以及作一些外部对接, 以及 技术实现的替换 , 例如, websocket 更换为 [ws](https://github.com/gobwas/ws))
- [ ] comet 增加 gRPC 与 rpc 接口, tcp /websocket 等扩展增加用户注册 /发送消息/ 变更聊天室 / 查看历史消息等
- [ ] 增加 gRPC 拦截 ( 支持 chatbot 等), 增加支持 消息历史存储/ relay 等接口

支持 nats 的应用程序在以下路径, 每个应用下的 toml 为对应的配置


### 文件结构
修改文件如下示意, 支持 nats 的应用程序在以下路径, 每个应用下的 toml 为对应的配置
/cmd/nats/discoveryd-config.toml 为 discovery 的配置

```
@@ -47,17 +70,14 @@ goim 是 非常成功的 IM ( 即时消息平台), 依赖项为 kafka ( 消息



### TODO
1. [x] 抽取 kafka 部分为 interface
2. [x] 增加测试
3. [x] 增加修改变更说明文档

### goim guide 安装/编译/使用指南(WIP)
参见 [/goim-usage-cn.md](goim-usage-cn.md) ( chinese )



goim v2.0
==============

[![Build Status](https://travis-ci.org/Terry-Mao/goim.svg?branch=master)](https://travis-ci.org/Terry-Mao/goim)
[![Go Report Card](https://goreportcard.com/badge/github.com/Terry-Mao/goim)](https://goreportcard.com/report/github.com/Terry-Mao/goim)
[![codecov](https://codecov.io/gh/Terry-Mao/goim/branch/master/graph/badge.svg)](https://codecov.io/gh/Terry-Mao/goim)
14 changes: 7 additions & 7 deletions cmd/nats/comet/main.go
Original file line number Diff line number Diff line change
@@ -16,13 +16,13 @@ import (

"github.com/tsingson/discovery/naming"
resolver "github.com/tsingson/discovery/naming/grpc"
"github.com/tsingson/fastx/utils"
"github.com/tsingson/ex-goim/pkg/utils"
log "github.com/tsingson/zaplogger"

"github.com/tsingson/ex-goim/internal/nats/comet"
"github.com/tsingson/ex-goim/internal/nats/comet/conf"
"github.com/tsingson/ex-goim/internal/nats/comet/grpc"
md "github.com/tsingson/ex-goim/internal/nats/model"
"github.com/tsingson/ex-goim/internal/nats/model"
"github.com/tsingson/ex-goim/pkg/ip"
)

@@ -118,9 +118,9 @@ func register(dis *naming.Discovery, srv *comet.Server) context.CancelFunc {
"grpc://" + addr + ":" + port,
},
Metadata: map[string]string{
md.MetaWeight: strconv.FormatInt(env.Weight, 10),
md.MetaOffline: strconv.FormatBool(env.Offline),
md.MetaAddrs: strings.Join(env.Addrs, ","),
model.MetaWeight: strconv.FormatInt(env.Weight, 10),
model.MetaOffline: strconv.FormatBool(env.Offline),
model.MetaAddrs: strings.Join(env.Addrs, ","),
},
}
cancel, err := dis.Register(ins)
@@ -141,8 +141,8 @@ func register(dis *naming.Discovery, srv *comet.Server) context.CancelFunc {
}
conns += bucket.ChannelCount()
}
ins.Metadata[md.MetaConnCount] = fmt.Sprint(conns)
ins.Metadata[md.MetaIPCount] = fmt.Sprint(len(ips))
ins.Metadata[model.MetaConnCount] = fmt.Sprint(conns)
ins.Metadata[model.MetaIPCount] = fmt.Sprint(len(ips))
if err = dis.Set(ins); err != nil {
log.Errorf("dis.Set(%+v) error(%v)", ins, err)
time.Sleep(time.Second)
34 changes: 31 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -7,35 +7,63 @@ require (
github.com/Workiva/go-datastructures v1.0.50 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/boltdb/bolt v1.3.1 // indirect
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.12+incompatible // indirect
github.com/coreos/go-semver v0.2.0 // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/gin-gonic/gin v1.3.0
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee // indirect
github.com/gobwas/pool v0.2.0 // indirect
github.com/gobwas/ws v1.0.0
github.com/gogo/protobuf v1.2.1
github.com/golang/protobuf v1.3.1
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/golang/protobuf v1.2.0
github.com/gomodule/redigo v2.0.0+incompatible
github.com/google/btree v1.0.0 // indirect
github.com/gorilla/websocket v1.4.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.8.5 // indirect
github.com/hako/durafmt v0.0.0-20180520121703-7b7ae1e72ead // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.5.3 // indirect
github.com/hashicorp/raft v1.0.0 // indirect
github.com/hashicorp/raft-boltdb v0.0.0-20171010151810-6e5ba93211ea // indirect
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/json-iterator/go v1.1.6 // indirect
github.com/liftbridge-io/go-liftbridge v0.0.0-20181231191109-b4f9a50124b8
github.com/liftbridge-io/liftbridge v0.0.0-20190328045118-ea1a979b5687 // indirect
github.com/liftbridge-io/nats-on-a-log v0.0.0-20180718011723-80d0727461af // indirect
github.com/mailru/easygo v0.0.0-20180630075556-0c8322a753d0
github.com/natefinch/atomic v0.0.0-20150920032501-a62ce929ffcc // indirect
github.com/nats-io/gnatsd v1.4.1 // indirect
github.com/nats-io/go-nats v1.7.2
github.com/nats-io/nkeys v0.0.2 // indirect
github.com/nats-io/nuid v1.0.0 // indirect
github.com/nsip/gommap v0.0.0-20181229045655-f7881c3a959f // indirect
github.com/pascaldekloe/goe v0.1.0 // indirect
github.com/prometheus/client_golang v0.9.2 // indirect
github.com/sacOO7/go-logger v0.0.0-20180719173527-9ac9add5a50d // indirect
github.com/sacOO7/gowebsocket v0.0.0-20180719182212-1436bb906a4e
github.com/sanity-io/litter v1.1.0
github.com/sirupsen/logrus v1.4.0 // indirect
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/stretchr/testify v1.3.0
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/tsingson/discovery v0.1.1
github.com/tsingson/fastx v0.3.1
github.com/tsingson/uuid v3.2.1+incompatible
github.com/tsingson/uuid v3.2.0+incompatible
github.com/tsingson/zaplogger v0.2.2
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
github.com/zhenjl/cityhash v0.0.0-20131128155616-cdd6a94144ab
golang.org/x/net v0.0.0-20190328230028-74de082e2cca
go.etcd.io/bbolt v1.3.2 // indirect
go.etcd.io/etcd v3.3.12+incompatible
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 // indirect
golang.org/x/net v0.0.0-20181220203305-927f97764cc3
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
golang.org/x/xerrors v0.0.0-20190315151331-d61658bd2e18
google.golang.org/grpc v1.19.1
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
Loading

0 comments on commit 430142f

Please sign in to comment.