Awesome Open Source
Awesome Open Source

gochat

Build Status contributions welcome

English version()

gochatgoim

  • gochatgo,,rpc,
  • websocket,tcp,websocket,tcp
  • etcd,
  • redis,,kafka,rabbitMQ
  • go,,gochat
  • docker,(docker)

Websocket && Tcp

websocket,tcp
tcppkg/stickpackage:stickpackage_test.goTest_TcpClient
stickpackage.gotcpPackUnpack
tcp4
androidiostcpgolangdemo
go test -v -count=1 *.go -test.run Test_TcpClient

tcp:
@todo,tcp70017002vps,
authTokentcptokentokenwebapijsonredistoken
authTokentcp

tcp,websockettcp
1tokenwebsocket,tcp
A1websocketB1tcp

2http
websocket,tcp

3taskrpcwebsockettcp
()

,,AB
1,Aapi,connect,
rpc call logicAconnectserverId,1

2,Bapi,connect,
rpc call logicBconnectserverId,1

3,Aapi,apirpc call logic,
logicpushtask

4,tasklogic,
(userId,roomId,serverId)BconnectserverId,
rpc call connect

5,connecttaskrpc call,
B,

6,,taskuserIdconnectserverId,
rpc call serverIdconnect

im,connectbucket:

connect:
    bucket: (bucket,)
        room: ()
            channel: ()

bucket

CityHashhash

server

  gochat git:(master)  tree -L 1
.
 api                  # api,rest api,rpc call logic, 
 architecture         # 
 bin                  # golang,git
 config               # 
 connect              # ,handler,,,rpc call logic,
 db                   # ,gochat.sqlite3sqlite,
 docker               # docker
 go.mod               # gomod
 go.sum               # gosum
 logic                # ,connectapirpc,push,task,
 main.go              # gochat
 proto                # golang rpc proto 
 readme.md            # 
 readme.en.md         # 
 reload.sh            # gochatsupervisorctl restart
 run.sh               # docker,demo
 site                 # ,,httpapi,
 task                 # ,,rpc call connect,
 tools                # 
 vendor               # vendor

golang

sqlite3 
mysql,
,sqlite,

ORMgorm 

etcd

rpcrpcx

:redis 
redis,kafkarabbitmq

:redis 
session,,

id:
snowflakeId,,
idqps409.6w/s,,DDOS

demo,,sqlite3,gorm,
,db


cd db && sqlite3 gochat.sqlite3
.tables
create table user(
  `id` INTEGER PRIMARY KEY autoincrement , -- 'id'
  `user_name` varchar(20) not null UNIQUE default '', -- ''
  `password` char(40) not null default '', -- ''
  `create_time` timestamp NOT NULL DEFAULT current_timestamp -- ''
);

,etcdredis,
7000, 7070, 8080tcp70017002tcp,
,connect,
connectserverId!

0,
go build -o gochat.bin -tags=etcd main.go

1,logic
./gochat.bin -module logic

2,connect
./gochat.bin -module connect_tcp
  
./gochat.bin -module connect_websocket

3,task
./gochat.bin -module task

4,api
./gochat.bin -module api 

5,,
./gochat.bin -module site

docker

,docker
docker,hub.docker.com,,

docker hub:

,
demo  111111
test  111111
admin 111111
1,docker pull lockgit/gochat:latest
2,git clone [email protected]:LockGit/gochat.git
3,cd gochat && sh run.sh dev (,sh,,sh run.sh dev./run.sh dev
4, http://127.0.0.1:8080 


,build dockerDockerfile
docker build -f docker/Dockerfile . -t lockgit/gochat
build:
1,git clone [email protected]:LockGit/gochat.git
2,cd gochat && sh run.sh dev (,sh,,sh run.sh dev./run.sh dev
3, http://127.0.0.1:8080 

vps,site/js/common.jssocketUrlapiUrlvpsip,
vps

demo

http://207.148.16.84:8080

,docker
,Chrome,,
,(:demotcp)

:
1http,websocket?
server demo im,websocketwebsockethttprpc call

2?

gochat,,,gochat
issue,

Backer and Sponsor

jetbrains

jetbrainsjetbrainslicense
jetbraninslicenselogo,

Support gochat

gochat

License

gochat is licensed under the MIT License.


Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Go (194,107
Websocket (5,264
Chat (3,217
Im (275
Related Projects