Skip to content

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

Merged
merged 27 commits into from
Apr 26, 2018
Merged

Feature/routing #1

merged 27 commits into from
Apr 26, 2018

Conversation

auxten
Copy link
Contributor

@auxten auxten commented Apr 25, 2018

consistent hash RPC works now

@xq262144
Copy link
Contributor

sofa

@auxten
Copy link
Contributor Author

auxten commented Apr 25, 2018

need some gofmt

@auxten auxten closed this Apr 25, 2018
@auxten auxten reopened this Apr 25, 2018
@auxten auxten closed this Apr 25, 2018
@auxten auxten reopened this Apr 25, 2018
@auxten
Copy link
Contributor Author

auxten commented Apr 25, 2018

ONLY UNITTEST WORKS SO FAR

@zeqing-guo
Copy link
Contributor

please add more comments next time

}

func (c *Consistent) Members() []Node {
c.RLock()
Copy link
Contributor Author

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 ..."

"github.com/thunderdb/ThunderDB/utils"
)

func NewNodeFromId(id string) Node {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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{
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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)
Copy link
Contributor Author

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)
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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{
Copy link
Contributor Author

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) {

Copy link
Contributor Author

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()
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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
Copy link
Contributor Author

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 ..."

@auxten auxten requested review from xq262144 and leventeliu April 26, 2018 10:39
Copy link
Contributor

@leventeliu leventeliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@auxten auxten merged commit 91c9886 into develop Apr 26, 2018
auxten pushed a commit that referenced this pull request Dec 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants