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

.

parent a62c9889
...@@ -71,19 +71,19 @@ type Master struct { ...@@ -71,19 +71,19 @@ type Master struct {
} }
// node connects // event: node connects
type nodeCome struct { type nodeCome struct {
link *neo.NodeLink link *neo.NodeLink
idReq neo.RequestIdentification // we received this identification request idReq neo.RequestIdentification // we received this identification request
idResp chan neo.Msg // what we reply (AcceptIdentification | Error) idResp chan neo.Msg // what we reply (AcceptIdentification | Error)
} }
// node disconnects // event: node disconnects
type nodeLeave struct { 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. // Use Run to actually start running the node.
func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master { func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
// convert serveAddr into neo format // convert serveAddr into neo format
...@@ -97,6 +97,13 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master { ...@@ -97,6 +97,13 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
clusterName: clusterName, clusterName: clusterName,
net: net, net: net,
masterAddr: serveAddr, // XXX ok? 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) m.myInfo.NodeUUID = m.allocUUID(neo.MASTER)
...@@ -718,7 +725,7 @@ func (m *Master) allocUUID(nodeType neo.NodeType) neo.NodeUUID { ...@@ -718,7 +725,7 @@ func (m *Master) allocUUID(nodeType neo.NodeType) neo.NodeUUID {
// XXX +error return? // XXX +error return?
func (m *Master) ServeLink(ctx context.Context, link *neo.NodeLink) { func (m *Master) ServeLink(ctx context.Context, link *neo.NodeLink) {
logf := func(format string, argv ...interface{}) { 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") logf("serving new node")
......
...@@ -39,7 +39,7 @@ type Server interface { ...@@ -39,7 +39,7 @@ type Server interface {
// Serve runs service on a listener // Serve runs service on a listener
// - accept incoming connection on the 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. // the listener is closed when Serve returns.
func Serve(ctx context.Context, l net.Listener, srv Server) error { func Serve(ctx context.Context, l net.Listener, srv Server) error {
......
...@@ -46,7 +46,7 @@ type Networker interface { ...@@ -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... // network is "tcp", "tcp4", "tcp6", "unix", etc...
func NetPlain(network string) Networker { func NetPlain(network string) Networker {
return netPlain(network) return netPlain(network)
...@@ -67,7 +67,7 @@ func (n netPlain) Listen(laddr string) (net.Listener, error) { ...@@ -67,7 +67,7 @@ func (n netPlain) Listen(laddr string) (net.Listener, error) {
return net.Listen(string(n), laddr) 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: // The config must be valid:
// - for tls.Client -- for Dial to work, // - for tls.Client -- for Dial to work,
// - for tls.Server -- for Listen 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