Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify absolute dependency path to relative and Add mid config #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,15 @@ _cgo_export.*

_testmain.go

*.exe
*.exe

.bundle
.DS_Store
*.swp
*.swo
*.swn
*.swm
.rvmrc
comet/comet
message/message
web/web
8 changes: 4 additions & 4 deletions comet/channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ package main
import (
log "code.google.com/p/log4go"
"errors"
"github.com/Terry-Mao/gopush-cluster/hash"
"github.com/Terry-Mao/gopush-cluster/hlist"
"github.com/Terry-Mao/gopush-cluster/ketama"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/hash"
"gopush-cluster/hlist"
"gopush-cluster/ketama"
myrpc "gopush-cluster/rpc"
"sync"
)

Expand Down
7 changes: 7 additions & 0 deletions comet/comet-example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,13 @@ auth no
# connection.
msgbuf.num 120


[message]

# yes is default, if yes message id will be long timestamp, if no message is will be short timestamp
# currently the short timestamp is makesence, because redis ZADD score is not supprt too long value , such as whole int64
mid_use_long_timestamp yes

################################## INCLUDES ###################################

# Include one or more other config files here. This is useful if you
Expand Down
11 changes: 9 additions & 2 deletions comet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ type Config struct {
WebsocketBind []string `goconf:"base:websocket.bind:,"`
RPCBind []string `goconf:"base:rpc.bind:,"`
PprofBind []string `goconf:"base:pprof.bind:,"`
StatBind []string `goconf:"base:stat.bind:,"`
StatBind []string `goconf:"base:stat.bind:,"`

//mid
MidIsUseLongTimestamp bool `goconf:"message:mid_use_long_timestamp"`

// zookeeper
ZookeeperAddr []string `goconf:"zookeeper:addr:,"`
ZookeeperTimeout time.Duration `goconf:"zookeeper:timeout:time"`
Expand All @@ -65,7 +69,8 @@ type Config struct {
ChannelBucket int `goconf:"channel:bucket"`
Auth bool `goconf:"channel:auth"`
TokenExpire time.Duration `goconf:"-"`
MsgBufNum int `goconf:"channel:msgbuf.num"`
MsgBufNum int `goconf:"channel:msgbuf.num"`

}

// InitConfig get a new Config struct.
Expand All @@ -82,6 +87,8 @@ func InitConfig() error {
RPCBind: []string{"localhost:6970"},
PprofBind: []string{"localhost:6971"},
StatBind: []string{"localhost:6972"},

MidIsUseLongTimestamp: true,
// zookeeper
ZookeeperAddr: []string{"localhost:2181"},
ZookeeperTimeout: 30 * time.Second,
Expand Down
6 changes: 3 additions & 3 deletions comet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package main
import (
log "code.google.com/p/log4go"
"flag"
"github.com/Terry-Mao/gopush-cluster/perf"
"github.com/Terry-Mao/gopush-cluster/process"
"github.com/Terry-Mao/gopush-cluster/ver"
"gopush-cluster/perf"
"gopush-cluster/process"
"gopush-cluster/ver"
"runtime"
)

Expand Down
8 changes: 5 additions & 3 deletions comet/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package main
import (
log "code.google.com/p/log4go"
"errors"
"github.com/Terry-Mao/gopush-cluster/id"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/id"
myrpc "gopush-cluster/rpc"
"net"
"net/rpc"
"sync"
Expand Down Expand Up @@ -174,7 +174,9 @@ func (c *CometRPC) PushPrivates(args *myrpc.CometPushPrivatesArgs, rw *myrpc.Com
}
b.Lock()
defer b.Unlock()
timeId := id.Get()

timeId := id.Get(Conf.MidIsUseLongTimestamp)

msg := &myrpc.Message{Msg: args.Msg, MsgId: timeId}
// private message need persistence
// if message expired no need persistence, only send online message
Expand Down
11 changes: 7 additions & 4 deletions comet/seq_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package main
import (
log "code.google.com/p/log4go"
"errors"
"github.com/Terry-Mao/gopush-cluster/hlist"
"github.com/Terry-Mao/gopush-cluster/id"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/hlist"
"gopush-cluster/id"
myrpc "gopush-cluster/rpc"
"sync"
)

Expand Down Expand Up @@ -138,7 +138,10 @@ func (c *SeqChannel) PushMsg(key string, m *myrpc.Message, expire uint) (err err
// if message expired no need persistence, only send online message
// rewrite message id
//m.MsgId = c.timeID.ID()
m.MsgId = id.Get()
m.MsgId = id.Get(Conf.MidIsUseLongTimestamp)

//log.Error("mid: %s", Conf.MidIsUseLongTimestamp)

if m.GroupId != myrpc.PublicGroupId && expire > 0 {
args := &myrpc.MessageSavePrivateArgs{Key: key, Msg: m.Msg, MsgId: m.MsgId, Expire: expire}
ret := 0
Expand Down
4 changes: 2 additions & 2 deletions comet/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ package main
import (
log "code.google.com/p/log4go"
"encoding/json"
"github.com/Terry-Mao/gopush-cluster/rpc"
myzk "github.com/Terry-Mao/gopush-cluster/zk"
"gopush-cluster/rpc"
myzk "gopush-cluster/zk"
"github.com/samuel/go-zookeeper/zk"
"path"
"time"
Expand Down
2 changes: 1 addition & 1 deletion dependencies.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Dependencies

go get -u github.com/Terry-Mao/gopush-cluster
#go get -u github.com/Terry-Mao/gopush-cluster
go get -u github.com/Terry-Mao/goconf
go get -u github.com/garyburd/redigo/redis
go get -u code.google.com/p/go.net/websocket
Expand Down
8 changes: 6 additions & 2 deletions id/timeid.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ func (t *TimeID) ID() int64 {
*/

// Get get a time id.
func Get() int64 {
return time.Now().UnixNano() / 100
func Get(long_timestamp bool) int64 {
if long_timestamp {
return time.Now().UnixNano() / 100
} else {
return time.Now().Unix()
}
}
6 changes: 3 additions & 3 deletions message/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package main
import (
log "code.google.com/p/log4go"
"flag"
"github.com/Terry-Mao/gopush-cluster/perf"
"github.com/Terry-Mao/gopush-cluster/process"
"github.com/Terry-Mao/gopush-cluster/ver"
"gopush-cluster/perf"
"gopush-cluster/process"
"gopush-cluster/ver"
"runtime"
)

Expand Down
4 changes: 2 additions & 2 deletions message/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"database/sql"
"encoding/json"
"errors"
"github.com/Terry-Mao/gopush-cluster/ketama"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/ketama"
myrpc "gopush-cluster/rpc"
_ "github.com/go-sql-driver/mysql"
"strconv"
"strings"
Expand Down
4 changes: 2 additions & 2 deletions message/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/Terry-Mao/gopush-cluster/ketama"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/ketama"
myrpc "gopush-cluster/rpc"
"github.com/garyburd/redigo/redis"
"strconv"
"strings"
Expand Down
2 changes: 1 addition & 1 deletion message/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
log "code.google.com/p/log4go"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
myrpc "gopush-cluster/rpc"
"net"
"net/rpc"
)
Expand Down
2 changes: 1 addition & 1 deletion message/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
log "code.google.com/p/log4go"
"encoding/json"
"errors"
"github.com/Terry-Mao/gopush-cluster/rpc"
"gopush-cluster/rpc"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions message/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ package main
import (
log "code.google.com/p/log4go"
"encoding/json"
"github.com/Terry-Mao/gopush-cluster/rpc"
myzk "github.com/Terry-Mao/gopush-cluster/zk"
"gopush-cluster/rpc"
myzk "gopush-cluster/zk"
"github.com/samuel/go-zookeeper/zk"
)

Expand Down
4 changes: 2 additions & 2 deletions rpc/comet.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
log "code.google.com/p/log4go"
"encoding/json"
"errors"
"github.com/Terry-Mao/gopush-cluster/ketama"
myzk "github.com/Terry-Mao/gopush-cluster/zk"
"gopush-cluster/ketama"
myzk "gopush-cluster/zk"
"github.com/samuel/go-zookeeper/zk"
"net/rpc"
"path"
Expand Down
2 changes: 1 addition & 1 deletion rpc/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package rpc
import (
log "code.google.com/p/log4go"
"encoding/json"
myzk "github.com/Terry-Mao/gopush-cluster/zk"
myzk "gopush-cluster/zk"
"github.com/samuel/go-zookeeper/zk"
"net/rpc"
"path"
Expand Down
2 changes: 1 addition & 1 deletion web/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package main
import (
log "code.google.com/p/log4go"
"encoding/json"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
myrpc "gopush-cluster/rpc"
"io/ioutil"
"net/http"
"net/url"
Expand Down
2 changes: 1 addition & 1 deletion web/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
log "code.google.com/p/log4go"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
myrpc "gopush-cluster/rpc"
"net/http"
"strconv"
"time"
Expand Down
2 changes: 1 addition & 1 deletion web/handle_1.0.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package main

import (
log "code.google.com/p/log4go"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
myrpc "gopush-cluster/rpc"
"net/http"
"strconv"
"time"
Expand Down
6 changes: 3 additions & 3 deletions web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package main
import (
log "code.google.com/p/log4go"
"flag"
"github.com/Terry-Mao/gopush-cluster/perf"
"github.com/Terry-Mao/gopush-cluster/process"
"github.com/Terry-Mao/gopush-cluster/ver"
"gopush-cluster/perf"
"gopush-cluster/process"
"gopush-cluster/ver"
"runtime"
)

Expand Down
4 changes: 2 additions & 2 deletions web/zk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package main

import (
log "code.google.com/p/log4go"
myrpc "github.com/Terry-Mao/gopush-cluster/rpc"
myzk "github.com/Terry-Mao/gopush-cluster/zk"
myrpc "gopush-cluster/rpc"
myzk "gopush-cluster/zk"
"github.com/samuel/go-zookeeper/zk"
)

Expand Down