lxd/cluster/raft.go
func raftNetworkTransport(
	db *db.Node,
	address string,
	logger *log.Logger,
	timeout time.Duration,
	dial rafthttp.Dial) (raft.Transport, *rafthttp.Handler, *rafthttp.Layer, error) {
	handler := rafthttp.NewHandlerWithLogger(logger)
	addr, err := net.ResolveTCPAddr("tcp", address)
	if err != nil {
		return nil, nil, nil, errors.Wrap(err, "invalid node address")
	}

	layer := rafthttp.NewLayer(raftEndpoint, addr, handler, dial)
	config := &raft.NetworkTransportConfig{
		Logger:                logger,
		Stream:                layer,
		MaxPool:               2,
		Timeout:               timeout,
		ServerAddressProvider: &raftAddressProvider{db: db},
	}
	transport := raft.NewNetworkTransportWithConfig(config)

	return transport, handler, layer, nil
}
func raftNetworkTransport(
	db *db.Node,
	address string,
	logger *log.Logger,
	timeout time.Duration,
	dial rafthttp.Dial) (raft.Transport, *rafthttp.Handler, *rafthttp.Layer, error) {
	handler := rafthttp.NewHandlerWithLogger(logger)
	addr, err := net.ResolveTCPAddr("tcp", address)
	if err != nil {
		return nil, nil, nil, errors.Wrap(err, "invalid node address")
	}

	layer := rafthttp.NewLayer(raftEndpoint, addr, handler, dial)
	config := &raft.NetworkTransportConfig{
		Logger:                logger,
		Stream:                layer,
		MaxPool:               2,
		Timeout:               timeout,
		ServerAddressProvider: &raftAddressProvider{db: db},
	}
	transport := raft.NewNetworkTransportWithConfig(config)

	return transport, handler, layer, nil
}
func raftNetworkTransport ( db * db . Node , address string , logger * log . Logger , timeout time . Duration , dial rafthttp . Dial ) ( raft . Transport , * rafthttp . Handler , * rafthttp . Layer , error ) { handler := rafthttp . NewHandlerWithLogger ( logger ) addr , err := net . ResolveTCPAddr ( " " , address ) if err != nil { return nil , nil , nil , errors . Wrap ( err , " " ) } layer := rafthttp . NewLayer ( raftEndpoint , addr , handler , dial ) config := & raft . NetworkTransportConfig { Logger : logger , Stream : layer , MaxPool : 2 , Timeout : timeout , ServerAddressProvider : & raftAddressProvider { db : db } , } transport := raft . NewNetworkTransportWithConfig ( config ) return transport , handler , layer , nil }
// Create a network raft transport that will handle connections using a
// rafthttp.Handler.
Create a network raft transport that will handle connections using a rafthttp . Handler .