Commit 81736b44 authored by Kirill Smelkov's avatar Kirill Smelkov

X Network -> Networker (there can be many access-points (Networkers) to 1 Network)

parent f5c1174f
......@@ -34,7 +34,7 @@ type Client struct {
myInfo neo.NodeInfo // XXX -> only NodeUUID
clusterName string
net xnet.Network // network we are sending/receiving on
net xnet.Networker // network AP we are sending/receiving on
masterAddr string // address of master XXX -> Address ?
// ---- 8< ----
......
......@@ -683,7 +683,7 @@ func handshake(ctx context.Context, conn net.Conn, version uint32) (err error) {
// ---- for convenience: Dial ----
// Dial connects to address on given network, handshakes and wraps the connection as NodeLink
func Dial(ctx context.Context, net xnet.Network, addr string) (nl *NodeLink, err error) {
func Dial(ctx context.Context, net xnet.Networker, addr string) (nl *NodeLink, err error) {
peerConn, err := net.Dial(ctx, addr)
if err != nil {
return nil, err
......
......@@ -40,7 +40,7 @@ type Master struct {
myInfo neo.NodeInfo
clusterName string
net xnet.Network // network we are sending/receiving on
net xnet.Networker // network AP we are sending/receiving on
masterAddr string // address of current primary master
// ---- 8< ----
......@@ -84,7 +84,7 @@ type nodeLeave struct {
// 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.Network) *Master {
func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
// convert serveAddr into neo format
addr, err := neo.AddrString(net.Network(), serveAddr)
if err != nil {
......
......@@ -38,7 +38,7 @@ type Storage struct {
myInfo neo.NodeInfo // XXX -> only Address + NodeUUID ?
clusterName string
net xnet.Network // network we are sending/receiving on
net xnet.Networker // network AP we are sending/receiving on
masterAddr string // address of master
// ---- 8< ----
......@@ -48,7 +48,7 @@ type Storage struct {
// NewStorage creates new storage node that will listen on serveAddr and talk to master on masterAddr
// The storage uses zstor as underlying backend for storing data.
// Use Run to actually start running the node.
func NewStorage(cluster, masterAddr, serveAddr string, net xnet.Network, zstor zodb.IStorage) *Storage {
func NewStorage(cluster, masterAddr, serveAddr string, net xnet.Networker, zstor zodb.IStorage) *Storage {
// convert serveAddr into neo format
addr, err := neo.AddrString(net.Network(), serveAddr)
if err != nil {
......
......@@ -25,13 +25,9 @@ import (
"crypto/tls"
)
// Network is the interface to work with various kinds of streaming networks
//
// NOTE in NEO a node usually needs to both 1) listen and serve incoming
// connections, and 2) dial peers. For this reason the interface is not split
// into Dialer and Listener.
type Network interface {
// Network returns name of the network
// Networker is interface representing access-point to a streaming network
type Networker interface {
// Network returns name of the network XXX recheck
Network() string
// Dial connects to addr on underlying network
......@@ -46,9 +42,9 @@ type Network interface {
}
// NetPlain creates Network corresponding to regular network
// NetPlain creates Networker corresponding to regular network accessors from std package net
// network is "tcp", "tcp4", "tcp6", "unix", etc...
func NetPlain(network string) Network {
func NetPlain(network string) Networker {
return netPlain(network)
}
......@@ -67,16 +63,16 @@ func (n netPlain) Listen(laddr string) (net.Listener, error) {
return net.Listen(string(n), laddr)
}
// NetTLS wraps underlying network 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.
func NetTLS(inner Network, config *tls.Config) Network {
func NetTLS(inner Networker, config *tls.Config) Networker {
return &netTLS{inner, config}
}
type netTLS struct {
inner Network
inner Networker
config *tls.Config
}
......
......@@ -24,7 +24,7 @@ import (
"net"
)
// NetTrace wraps underlying network with IO tracing layer
// NetTrace wraps underlying networker with IO tracing layer
//
// Tracing is done via calling trace func right before corresponding packet
// is sent for Tx to underlying network. No synchronization for notification is
......@@ -34,7 +34,7 @@ import (
// only Tx events are traced:
// - because Write, contrary to Read, never writes partial data on non-error
// - because in case of pipenet tracing writes only is enough to get whole network exchange picture
func NetTrace(inner Network, tracer Tracer) Network {
func NetTrace(inner Networker, tracer Tracer) Networker {
return &netTrace{inner, tracer}
}
......@@ -62,10 +62,10 @@ type TraceTx struct {
Pkt []byte
}
// netTrace wraps underlying Network such that whenever a connection is created
// netTrace wraps underlying Networker such that whenever a connection is created
// it is wrapped with traceConn
type netTrace struct {
inner Network
inner Networker
tracer Tracer
}
......
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