You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by "Zhen Wang (JIRA)" <ji...@apache.org> on 2008/07/10 20:54:31 UTC

[jira] Created: (SHINDIG-441) Asynchronous rpc handler support

Asynchronous rpc handler support
--------------------------------

                 Key: SHINDIG-441
                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
             Project: Shindig
          Issue Type: New Feature
          Components: Features (Javascript)
            Reporter: Zhen Wang


Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.

Proposed solution:
Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.

Patch to rpc.js:
232,236d231
<       if (rpc.c) {
<         rpc.callback = function(result) {
<           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
<         };
<       }
242c237
<       if (rpc.c && typeof result != 'undefined') {
---
>       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "Paul Lindner (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612609#action_12612609 ] 

Paul Lindner commented on SHINDIG-441:
--------------------------------------

I like!  This will simplify a lot of code where we have to create RPC code for forward and reverse calls.

Thanks!


> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "John Hjelmstad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612726#action_12612726 ] 

John Hjelmstad commented on SHINDIG-441:
----------------------------------------

So it just occurred to me that what I'm getting at here is standardization of RPC handlers - which I agree isn't something that's standardized at all. Anyhow, I never had any opposition to including this anyway -- it's clean, compact, and useful, so we should go ahead with it :)

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "John Hjelmstad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612716#action_12612716 ] 

John Hjelmstad commented on SHINDIG-441:
----------------------------------------

As commented in SHINDIG-442, this changes how the callback function is used.

If we accept the premise that gadgets.rpc is _only_ for gadget-to-container calls, and not the inverse, _and_ that the spec is only relevant to the gadgets API and not the container-side, then I agree, this doesn't affect the spec.

Also as mentioned in that issue, I like this implementation, despite the passing-by-context oddity. I just want to flesh out the boundaries of the spec through this discussion (and the other too, I guess).

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "Zhen Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612721#action_12612721 ] 

Zhen Wang commented on SHINDIG-441:
-----------------------------------

But neither gadget-to-container nor container-to-gadget rpc callback functions will be affected at all. Whether an rpc handler processes a request synchronously or asynchronously is opaque to rpc callers.

And your quote of the spec refers to the gadget API which won't be changed. Container-side implementation of rpc handlers is not defined by the spec.

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (SHINDIG-441) Asynchronous rpc handler support

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

Zhen Wang closed SHINDIG-441.
-----------------------------

    Resolution: Fixed

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "Zhen Wang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612710#action_12612710 ] 

Zhen Wang commented on SHINDIG-441:
-----------------------------------

I don't get your point. The patch doesn't require any changes to the callback function.

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (SHINDIG-441) Asynchronous rpc handler support

Posted by "John Hjelmstad (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SHINDIG-441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612696#action_12612696 ] 

John Hjelmstad commented on SHINDIG-441:
----------------------------------------

Technically this requires a spec change.

The spec says this about the callback function provided to gadgets.rpc.call:
"Callback function (if any) to process the return value of the RPC request."

Because the callback function is invalidated when using it asynchronously, the return value will then be lost (or vice versa). This can be fixed in a backward-compatible way by not removing the callback if called asynchronously, but that sort of ruins the point of the CL.

> Asynchronous rpc handler support
> --------------------------------
>
>                 Key: SHINDIG-441
>                 URL: https://issues.apache.org/jira/browse/SHINDIG-441
>             Project: Shindig
>          Issue Type: New Feature
>          Components: Features (Javascript)
>            Reporter: Zhen Wang
>
> Currently an gadget rpc handler must be synchronous. Its return value is immediately passed back to the rpc caller if a callback function is defined. This prevents an rpc request handler to make some asynchronous calls and return a value later.
> Proposed solution:
> Add a callback method to the rpc context object for an rpc request handler to return a value asynchronously.
> This won't affect existing code. Synchronous handlers may simply ignore the change and return a value as usual while async handlers don't return a value immediately and call "this.callback(return_value);" when ready.
> Patch to rpc.js:
> 232,236d231
> <       if (rpc.c) {
> <         rpc.callback = function(result) {
> <           gadgets.rpc.call(rpc.f, CALLBACK_NAME, null, rpc.c, result);
> <         };
> <       }
> 242c237
> <       if (rpc.c && typeof result != 'undefined') {
> ---
> >       if (rpc.c) {

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.