Commit 9c3998b9 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent a62c9889
......@@ -71,19 +71,19 @@ type Master struct {
}
// node connects
// event: node connects
type nodeCome struct {
link *neo.NodeLink
idReq neo.RequestIdentification // we received this identification request
idResp chan neo.Msg // what we reply (AcceptIdentification | Error)
}
// node disconnects
// event: node disconnects
type nodeLeave struct {
link *neo.NodeLink // XXX better use uuid allocated on nodeCome ?
link *neo.NodeLink // XXX better use uuid allocated on nodeCome
}
// NewMaster creates new master node that will listen on serveAddr
// NewMaster creates new master node that will listen on serveAddr.
// Use Run to actually start running the node.
func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
// convert serveAddr into neo format
......@@ -97,6 +97,13 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
clusterName: clusterName,
net: net,
masterAddr: serveAddr, // XXX ok?
ctlStart: make(chan chan error),
ctlStop: make(chan chan error),
ctlShutdown: make(chan chan error),
nodeCome: make(chan nodeCome),
nodeLeave: make(chan nodeLeave),
}
m.myInfo.NodeUUID = m.allocUUID(neo.MASTER)
......@@ -718,7 +725,7 @@ func (m *Master) allocUUID(nodeType neo.NodeType) neo.NodeUUID {
// XXX +error return?
func (m *Master) ServeLink(ctx context.Context, link *neo.NodeLink) {
logf := func(format string, argv ...interface{}) {
fmt.Printf("master: %s: " + format + "\n", append([]interface{}{link}, argv...))
fmt.Printf("master: %s: " + format + "\n", append([]interface{}{link}, argv...)...)
}
logf("serving new node")
......
......@@ -39,7 +39,7 @@ type Server interface {
// Serve runs service on a listener
// - accept incoming connection on the listener
// - for every accepted connection spawn srv.ServeLink() in separate goroutine.
// - for every accepted connection spawn handshake + srv.ServeLink() in separate goroutine.
//
// the listener is closed when Serve returns.
func Serve(ctx context.Context, l net.Listener, srv Server) error {
......
......@@ -46,7 +46,7 @@ type Networker interface {
}
// NetPlain creates Networker corresponding to regular network accessors from std package net
// NetPlain creates Networker corresponding to regular network accessors from std package net.
// network is "tcp", "tcp4", "tcp6", "unix", etc...
func NetPlain(network string) Networker {
return netPlain(network)
......@@ -67,7 +67,7 @@ func (n netPlain) Listen(laddr string) (net.Listener, error) {
return net.Listen(string(n), laddr)
}
// NetTLS wraps underlying networker with TLS layer according to config
// NetTLS wraps underlying networker with TLS layer according to config.
// The config must be valid:
// - for tls.Client -- for Dial to work,
// - for tls.Server -- for Listen to work.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment