net_transport.go
func (n *NetworkTransport) InstallSnapshot(id ServerID, target ServerAddress, args *InstallSnapshotRequest, resp *InstallSnapshotResponse, data io.Reader) error {
	// Get a conn, always close for InstallSnapshot
	conn, err := n.getConnFromAddressProvider(id, target)
	if err != nil {
		return err
	}
	defer conn.Release()

	// Set a deadline, scaled by request size
	if n.timeout > 0 {
		timeout := n.timeout * time.Duration(args.Size/int64(n.TimeoutScale))
		if timeout < n.timeout {
			timeout = n.timeout
		}
		conn.conn.SetDeadline(time.Now().Add(timeout))
	}

	// Send the RPC
	if err = sendRPC(conn, rpcInstallSnapshot, args); err != nil {
		return err
	}

	// Stream the state
	if _, err = io.Copy(conn.w, data); err != nil {
		return err
	}

	// Flush
	if err = conn.w.Flush(); err != nil {
		return err
	}

	// Decode the response, do not return conn
	_, err = decodeResponse(conn, resp)
	return err
}
func (n *NetworkTransport) InstallSnapshot(id ServerID, target ServerAddress, args *InstallSnapshotRequest, resp *InstallSnapshotResponse, data io.Reader) error {
	// Get a conn, always close for InstallSnapshot
	conn, err := n.getConnFromAddressProvider(id, target)
	if err != nil {
		return err
	}
	defer conn.Release()

	// Set a deadline, scaled by request size
	if n.timeout > 0 {
		timeout := n.timeout * time.Duration(args.Size/int64(n.TimeoutScale))
		if timeout < n.timeout {
			timeout = n.timeout
		}
		conn.conn.SetDeadline(time.Now().Add(timeout))
	}

	// Send the RPC
	if err = sendRPC(conn, rpcInstallSnapshot, args); err != nil {
		return err
	}

	// Stream the state
	if _, err = io.Copy(conn.w, data); err != nil {
		return err
	}

	// Flush
	if err = conn.w.Flush(); err != nil {
		return err
	}

	// Decode the response, do not return conn
	_, err = decodeResponse(conn, resp)
	return err
}
func ( n * NetworkTransport ) InstallSnapshot ( id ServerID , target ServerAddress , args * InstallSnapshotRequest , resp * InstallSnapshotResponse , data io . Reader ) error { // Get a conn, always close for InstallSnapshot conn , err := n . getConnFromAddressProvider ( id , target ) if err != nil { return err } defer conn . Release ( ) // Set a deadline, scaled by request size if n . timeout > 0 { timeout := n . timeout * time . Duration ( args . Size / int64 ( n . TimeoutScale ) ) if timeout < n . timeout { timeout = n . timeout } conn . conn . SetDeadline ( time . Now ( ) . Add ( timeout ) ) } // Send the RPC if err = sendRPC ( conn , rpcInstallSnapshot , args ) ; err != nil { return err } // Stream the state if _ , err = io . Copy ( conn . w , data ) ; err != nil { return err } // Flush if err = conn . w . Flush ( ) ; err != nil { return err } // Decode the response, do not return conn _ , err = decodeResponse ( conn , resp ) return err }
// InstallSnapshot implements the Transport interface.
InstallSnapshot implements the Transport interface .