Feature/routing#1
Conversation
…ad of crc32, fix test case
|
sofa |
|
need some gofmt |
|
ONLY UNITTEST WORKS SO FAR |
|
please add more comments next time |
| } | ||
|
|
||
| func (c *Consistent) Members() []Node { | ||
| c.RLock() |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
comment on exported method Consistent.Members should be of the form "Members ..."
| "github.com/thunderdb/ThunderDB/utils" | ||
| ) | ||
|
|
||
| func NewNodeFromId(id string) Node { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
func NewNodeFromId should be NewNodeFromID
| @@ -0,0 +1,12 @@ | |||
| package proto | |||
|
|
|||
| type NodeId string | |||
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type NodeID should have comment or be unexported
| package proto | ||
|
|
||
| type NodeId string | ||
| type NodeKey uint64 |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type NodeKey should have comment or be unexported
| type NodeId string | ||
| type NodeKey uint64 | ||
|
|
||
| type Node struct { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type Node should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func (s *Session) Close() { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Session.Close should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| "net" | ||
| ) | ||
|
|
||
| func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
| hashRing *consistent.Consistent | ||
| } | ||
|
|
||
| func NewDhtService() *DhtService { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewDHTService should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| "net" | ||
| ) | ||
|
|
||
| func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
| } | ||
|
|
||
| func NewDhtService() *DhtService { | ||
| return &DhtService{ |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewDHTService should have comment or be unexported
| } | ||
|
|
||
| type GetNeighborsReq struct { | ||
| NodeId proto.NodeId |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type GetNeighborsReq should have comment or be unexported
| } | ||
|
|
||
| type GetNeighborsResp struct { | ||
| Nodes []proto.Node |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported type GetNeighborsResp should have comment or be unexported
| } | ||
|
|
||
| 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.
[golint] reported by reviewdog 🐶
exported method DHTService.GetNeighbors should have comment or be unexported
| } | ||
|
|
||
| func (dht *DhtService) AddNode(req *AddNodeReq, resp *AddNodeResp) (err error) { | ||
| dht.hashRing.Add(req.Node) |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method DHTService.AddNode should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| "net" | ||
| ) | ||
|
|
||
| func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function InitDHTerver should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| "net" | ||
| ) | ||
|
|
||
| func InitDhtServer(l net.Listener) (server *rpc.Server, err error) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
comment on exported function InitDHTserver should be of the form "InitDHTserver ..."
| } | ||
|
|
||
| func NewServer() *Server { | ||
| return &Server{ |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewServer should have comment or be unexported
| } | ||
|
|
||
| func NewServerWithService(serviceMap ServiceMap) (server *Server, err error) { | ||
|
|
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewServerWithService should have comment or be unexported
| } | ||
|
|
||
| func (s *Server) serveRpc(sess *yamux.Session) { | ||
| conn, err := sess.Accept() |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Server.SetListener should have comment or be unexported
|
|
||
| func (s *Server) Serve(l net.Listener) { | ||
| serverLoop: | ||
| for { |
There was a problem hiding this comment.
[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.
[golint] reported by reviewdog 🐶
exported method Server.Serve should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| "net" | ||
| ) | ||
|
|
||
| // InitDHTserver |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
comment on exported function InitDHTserver should be of the form "InitDHTserver ..."
| listener net.Listener | ||
| } | ||
|
|
||
| func NewServer() *Server { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function NewServer should have comment or be unexported
| return server, nil | ||
| } | ||
|
|
||
| func (s *Server) SetListener(l net.Listener) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Server.SetListener should have comment or be unexported
| log.Debugf("%s closed connection", conn.RemoteAddr()) | ||
| } | ||
|
|
||
| func (s *Server) RegisterService(name string, service interface{}) error { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Server.RegisterService should have comment or be unexported
| return s.rpcServer.RegisterName(name, service) | ||
| } | ||
|
|
||
| func (s *Server) Serve() { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported method Server.Serve should have comment or be unexported
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
|
|
||
| import "testing" | ||
|
|
||
| func CheckNum(num, expected int, t *testing.T) { |
There was a problem hiding this comment.
[golint] reported by reviewdog 🐶
exported function CheckNum should have comment or be unexported
| } | ||
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| } | ||
|
|
||
| func CheckStr(str, expected string, t *testing.T) { | ||
| if str != expected { |
There was a problem hiding this comment.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
| } | ||
| } | ||
|
|
||
| // ChechStr make string assertion |
There was a problem hiding this comment.
[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.
[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.
[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.
[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.
[golint] reported by reviewdog 🐶
comment on exported var ErrRecvWindowExceeded should be of the form "ErrRecvWindowExceeded ..."
consistent hash RPC works now