AAARRRGGGGHHHH!!!
How hard does any of this need to be? I'm posting this here and against the Railo bug report I started typing it into "CFHTTP accept callback UDF to report progress" (RAILO-3131). As it's stroppy, Micha should feel welcome to delete it from Jira. However it's staying here.
Summary:
Brad raised this:
Allow CFHTTP to accept a closure which will be called every time 1% of the file has been downloaded. Include the size so far, total size, current percentage, and possibly a KB/s measurement in the data available to the closure. Perhaps the closure could simply be passed the cfhttp structure that is normally available at the end of the call, but it would be populated with the data available so far (including status code, headers, etc, and any new values necessary such as percent done.)
<cfhttp method="Get" url="http://www,remoteServer.com/bigFile.txt" progressUDF=function( cfhttp ) { ... Alert the user ... } >
Excellent suggestion. I suggested this:
I'm all for this sort of functionality being added to the language, but perhaps at a broader level. There's nothing wrong with Brad's approach when taken in isolation - it's a good idea - but there is probably a "bigger picture" that can be looked at when it comes to async programming.
And Micha then added this:
small addition: Railo 5 will have a tag named "cftask", this will be a lightway version ofMy reaction to that was one of horror, and I returned:. In other words Railo will create a task that get executed asychron, like cfthread-task this task is persistent, means it does survive a restart of the engine.
<cftask> <cfhttp ...> <!--- handle cfhttp result here ---> </cftask>
Please please please don't add this as a tag. Add it as a function which takes a function, eg:The functionality is fine, but it's simply not a tag. it doesn't make sense as a tag. It should not be implemented as a tag. If it's implemented as a function, we don't need two different versions: a function will work in both tags-based code and script-based code.
runTask(function(){ // stuff goes here });
Micha's fed back with some facile nonsense, and I have become non-plussed. I'm adding this one last comment, and then moving on. I've tried.
You really let yourself down with obtuse rationalisations like suggesting theThis is the reason why I think Railo's entire approach of implementing CFScript "equivalents" of tags simply by swapping outcomponent
keyword is a tag. It's not, in any way that a sensible person would define it. So let's dispense with that, shall we? Good.
Your suggestion requires two language constructs:
<cftask>
and
task{}
Mine just requires the one function for both purposes:
or:<cfset runTask()>
runTask()
One doesn't need two constructs. You're the one cluttering the language, not me.
<cf
and >
is TBH, I think two - fairly controversial - things:
- deprecate all this "tags" without angle-brackets nonsense in Railo's CFScript solution, and re-work it properly with well-thought-out, situation-specific and elegant solutions;
- form a language design committee to lead the direction of the language, in which Micha has a vote, but doesn't make the final decision. There's been a few poor ones, recently and I think he's out of his depth.
Thoughts?
--
Adam