You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Henrique Mendonca (JIRA)" <ji...@apache.org> on 2011/03/09 12:50:59 UTC

[jira] Created: (THRIFT-1087) Nonblocking asynchronous JS services

Nonblocking asynchronous JS services
------------------------------------

                 Key: THRIFT-1087
                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
             Project: Thrift
          Issue Type: New Feature
          Components: JavaScript - Compiler, JavaScript - Library
    Affects Versions: 0.6
            Reporter: Henrique Mendonca
            Assignee: Henrique Mendonca



The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.

Current trunk:
{quote}
MyServiceClient.prototype.getMyObject = function (objectId) \{
  this.send_getMyObject(objectId)   //send request and wait for response
  return this.recv_getMyObject()      //interpret response
}
{quote}


I propose something like this: (pseudo-code + extra verbose for better understanding)
{quote}
MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
  if ( ! onSucessHandler) \{
    this.send_getMyObject(objectId)   //send request and wait for response
    return this.recv_getMyObject()      //interpret response
  } else \{
    Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
    Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
    return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
  }
}
{quote}

I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
and it will still keep the compatibility with legacy code.

Any thoughts or ideas?


--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016414#comment-13016414 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

Hi Jake,

Do you mean something like that:
{noformat}
  jqRequest: function(client, postData, args, recv_method) {
+   if (typeof jQuery === 'undefined' || typeof jQuery.Deferred === 'undefined') {
+     throw 'Thrift.js requires jQuery 1.5+ to use asynchronous requests';
+   }
+
{noformat}

At the moment we only get something like:
{noformat}
'jQuery'/'jQuery.Deferred' is undefined
URI: /js/lib/thrift.js
{noformat}

And I have to agree with you that this is not very informative.

Shall I add this and Roger's change to the patch?

Cheers

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004633#comment-13004633 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

Thanks Jake, I am doing exactly the same in my current project. However, I do not think this is really practical if you want to use async calls for every service...

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: New Feature
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13013022#comment-13013022 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

I +1 on that, it might provide a better error handling too

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "T Jake Luciani (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016416#comment-13016416 ] 

T Jake Luciani commented on THRIFT-1087:
----------------------------------------

Yes, that's perfect.

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Roger Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13012188#comment-13012188 ] 

Roger Meier commented on THRIFT-1087:
-------------------------------------

What about using jQuery as a dependency for Thrift?
... or use some functions to check the availability of jQuery

and use jQuery.post and all the other stuff we need for async?

or create a jQuery plugin?

{noformat}
-        this.robj = eval(this.transport.readAll());
+        if (typeof jQuery !== 'undefined') {
+            this.robj = jQuery.parseJSON(this.transport.readAll());
+        }
+        else {
+            this.robj = eval(this.transport.readAll());
+        }
{noformat}

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henrique Mendonca updated THRIFT-1087:
--------------------------------------

    Attachment: THRIFT-1087-jquery-async-qunit-v2.patch

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit-v2.patch, THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Updated] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henrique Mendonca updated THRIFT-1087:
--------------------------------------

    Attachment: THRIFT-1087-jquery-async-qunit.patch

THRIFT-1087-jquery-async-qunit.patch

Add support jQuery ajax for asynchronous requests:
{noformat}
client.testByte(0x01, function(result) {
  equals(result, 0x01);
});
{noformat}

It uses a deferred object, so we can attach events like the normal jquery ajax calls:
{noformat}
.error( function(error) {  alert(error); } )
.success(function(result) {
  alert("Success: " + result);
})
.complete(function() {
  alert("complete");
})
{noformat}


I am not sure if we really need a separated generator (js:jquery) since it only needs jQuery if the user adds a callback function to the parameter list.
e.g.  *client.testByte(0x01)* still returns the result synchronously without even using jQuery.

What do you guys think?

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016427#comment-13016427 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

Done (/)

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit-v2.patch, THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004493#comment-13004493 ] 

Henrique Mendonca commented on THRIFT-1087:
-------------------------------------------

{quote}
*Performance Note*   When _bAsync_ is set to false, *send* operations are synchronous, and Windows Internet Explorer does not accept input or produce output while *send* operations are in progress. Therefore, this setting should not be used in situations where it is possible for a user to be waiting on the *send* operation to complete.
{quote}
_From MSDN:_ http://msdn.microsoft.com/en-us/library/ms536648%28v=vs.85%29.aspx

The same happens with most of the current browsers

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: New Feature
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Roger Meier (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004623#comment-13004623 ] 

Roger Meier commented on THRIFT-1087:
-------------------------------------

This would be a great improvement for the JavaScript bindings!


Could you provide a patch?

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: New Feature
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Resolved] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Roger Meier (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Roger Meier resolved THRIFT-1087.
---------------------------------

    Resolution: Fixed

Great Henrique!
I just committed your patch!



> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit-v2.patch, THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "T Jake Luciani (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016396#comment-13016396 ] 

T Jake Luciani commented on THRIFT-1087:
----------------------------------------

Can you add a check to error gracefully is jQuery is not detected?

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Updated: (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Henrique Mendonca (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henrique Mendonca updated THRIFT-1087:
--------------------------------------

    Issue Type: Sub-task  (was: New Feature)
        Parent: THRIFT-1

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] [Commented] (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13016562#comment-13016562 ] 

Hudson commented on THRIFT-1087:
--------------------------------

Integrated in Thrift #113 (See [https://hudson.apache.org/hudson/job/Thrift/113/])
    THRIFT-1087 Nonblocking asynchronous JS services
Patch: Henrique Mendonca


> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: Sub-task
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>         Attachments: THRIFT-1087-jquery-async-qunit-v2.patch, THRIFT-1087-jquery-async-qunit.patch
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

[jira] Commented: (THRIFT-1087) Nonblocking asynchronous JS services

Posted by "T Jake Luciani (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-1087?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13004629#comment-13004629 ] 

T Jake Luciani commented on THRIFT-1087:
----------------------------------------

There is a async example commented out in the current test: L232 http://svn.apache.org/viewvc/thrift/trunk/lib/js/test/test.html?view=markup

> Nonblocking asynchronous JS services
> ------------------------------------
>
>                 Key: THRIFT-1087
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1087
>             Project: Thrift
>          Issue Type: New Feature
>          Components: JavaScript - Compiler, JavaScript - Library
>    Affects Versions: 0.6
>            Reporter: Henrique Mendonca
>            Assignee: Henrique Mendonca
>              Labels: javascript, thrift
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>
> The current js lib uses an ajax synchronous request, which is not very typical for javascript. Since the current browsers' js are still single threaded, they block the whole website until we get an answer from the server.
> Current trunk:
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId) \{
>   this.send_getMyObject(objectId)   //send request and wait for response
>   return this.recv_getMyObject()      //interpret response
> }
> {quote}
> I propose something like this: (pseudo-code + extra verbose for better understanding)
> {quote}
> MyServiceClient.prototype.getMyObject = function (objectId, onSuccessHandler) \{
>   if ( ! onSucessHandler) \{
>     this.send_getMyObject(objectId)   //send request and wait for response
>     return this.recv_getMyObject()      //interpret response
>   } else \{
>     Thrift.HttpRequest.post( send_getMyObject(objectId) );   //send request asynchronously
>     Thrift.HttpRequest.onreadystatechange = function () \{ onSuccessHandler( this.recv_getMyObject() ); } //call handler on success
>     return Thrift.HttpRequest   //return request object, as user might need to attach an onError handler
>   }
> }
> {quote}
> I think it should be something similar to the jQuery post: http://api.jquery.com/jQuery.post/
> and it will still keep the compatibility with legacy code.
> Any thoughts or ideas?

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira