-
Notifications
You must be signed in to change notification settings - Fork 146
Feature/routing #1
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
Conversation
…ad of crc32, fix test case
sofa |
need some gofmt |
ONLY UNITTEST WORKS SO FAR |
please add more comments next time |
consistent/consistent.go
Outdated
} | ||
|
||
func (c *Consistent) Members() []Node { | ||
c.RLock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Consistent.Members should be of the form "Members ..."
consistent/consistent_test.go
Outdated
"github.com/thunderdb/ThunderDB/utils" | ||
) | ||
|
||
func NewNodeFromId(id string) Node { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
func NewNodeFromId should be NewNodeFromID
proto/proto.go
Outdated
@@ -0,0 +1,12 @@ | |||
package proto | |||
|
|||
type NodeId string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type NodeID should have comment or be unexported
proto/proto.go
Outdated
package proto | ||
|
||
type NodeId string | ||
type NodeKey uint64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type NodeKey should have comment or be unexported
proto/proto.go
Outdated
type NodeId string | ||
type NodeKey uint64 | ||
|
||
type Node struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type Node should have comment or be unexported
rpc/session.go
Outdated
} | ||
} | ||
|
||
func (s *Session) Close() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Session.Close should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
route/dht.go
Outdated
"net" | ||
) | ||
|
||
func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
route/service.go
Outdated
hashRing *consistent.Consistent | ||
} | ||
|
||
func NewDhtService() *DhtService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewDHTService should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
route/dht.go
Outdated
"net" | ||
) | ||
|
||
func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
route/service.go
Outdated
} | ||
|
||
func NewDhtService() *DhtService { | ||
return &DhtService{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewDHTService should have comment or be unexported
route/service.go
Outdated
} | ||
|
||
type GetNeighborsReq struct { | ||
NodeId proto.NodeId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type GetNeighborsReq should have comment or be unexported
route/service.go
Outdated
} | ||
|
||
type GetNeighborsResp struct { | ||
Nodes []proto.Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported type GetNeighborsResp should have comment or be unexported
route/service.go
Outdated
} | ||
|
||
func (dht *DhtService) GetNeighbors(req *GetNeighborsReq, resp *GetNeighborsResp) (err error) { | ||
resp.Nodes, err = dht.hashRing.GetN(string(req.NodeId), req.Count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method DHTService.GetNeighbors should have comment or be unexported
route/service.go
Outdated
} | ||
|
||
func (dht *DhtService) AddNode(req *AddNodeReq, resp *AddNodeResp) (err error) { | ||
dht.hashRing.Add(req.Node) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method DHTService.AddNode should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
route/dht.go
Outdated
"net" | ||
) | ||
|
||
func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
route/dht.go
Outdated
"net" | ||
) | ||
|
||
func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function InitDHTserver should be of the form "InitDHTserver ..."
rpc/server.go
Outdated
} | ||
|
||
func NewServer() *Server { | ||
return &Server{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewServer should have comment or be unexported
rpc/server.go
Outdated
} | ||
|
||
func NewServerWithService(serviceMap ServiceMap) (server *Server, err error) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewServerWithService should have comment or be unexported
rpc/server.go
Outdated
} | ||
|
||
func (s *Server) serveRpc(sess *yamux.Session) { | ||
conn, err := sess.Accept() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.SetListener should have comment or be unexported
rpc/server.go
Outdated
|
||
func (s *Server) Serve(l net.Listener) { | ||
serverLoop: | ||
for { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.RegisterService should have comment or be unexported
select { | ||
case <-s.stopCh: | ||
log.Info("Stopping Server Loop") | ||
break serverLoop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.Serve should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
route/dht.go
Outdated
"net" | ||
) | ||
|
||
// InitDHTserver |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function InitDHTserver should be of the form "InitDHTserver ..."
rpc/server.go
Outdated
listener net.Listener | ||
} | ||
|
||
func NewServer() *Server { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function NewServer should have comment or be unexported
rpc/server.go
Outdated
return server, nil | ||
} | ||
|
||
func (s *Server) SetListener(l net.Listener) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.SetListener should have comment or be unexported
rpc/server.go
Outdated
log.Debugf("%s closed connection", conn.RemoteAddr()) | ||
} | ||
|
||
func (s *Server) RegisterService(name string, service interface{}) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.RegisterService should have comment or be unexported
rpc/server.go
Outdated
return s.rpcServer.RegisterName(name, service) | ||
} | ||
|
||
func (s *Server) Serve() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported method Server.Serve should have comment or be unexported
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
utils/test.go
Outdated
|
||
import "testing" | ||
|
||
func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
utils/test.go
Outdated
} | ||
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
exported function CheckStr should have comment or be unexported
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
utils/test.go
Outdated
} | ||
|
||
func CheckStr(str, expected string, t *testing.T) { | ||
if str != expected { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function CheckStr should be of the form "CheckStr ..."
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
utils/test.go
Outdated
} | ||
} | ||
|
||
// ChechStr make string assertion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported function CheckStr should be of the form "CheckStr ..."
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
return s.session.LocalAddr() | ||
} | ||
|
||
// LocalAddr returns the remote address |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported method Stream.RemoteAddr should be of the form "RemoteAddr ..."
// opened inbound | ||
ErrDuplicateStream = fmt.Errorf("duplicate stream initiated") | ||
|
||
// ErrReceiveWindowExceeded indicates the window was exceeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
consistent hash RPC works now