You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by jo...@gmail.com on 2009/07/14 23:11:40 UTC

Use dummy fallback for gadgets.rpc rather than IFPC

Reviewers: shindig.remailer_gmail.com,

Description:
In my experience, use of IFPC as a "fallback" mechanism for gadgets.rpc
has not been useful.

* The fallback tends most often to be selected in cases of
misconfiguration. We should just emit a simple-to-understand error in
such cases and move on. Most of the time IFPC doesn't work in these
circumstances either.

* If fallback occurs due to a transport bug, this bug may be obscured by
IFPC (or whatever fallback there is) working properly. This causes
frustrating, difficult-to-reproduce errors.

* In some cases, gadgets are embedded in contexts without access to an
RPC relay (eg. in syndicated gadget rendering). Falling back to IFPC
yields rpc_relay.html 404s.

* Falling back to another transport introduces timing issues stemming
from the multiple ways in which a fallback could occur: during init,
setup, or call, each of which requires a particular handshake to
reoccur.

To remedy this, I propose replacing fallbackTransport with a dummy tx
impl that simply logs (using gadgets.info, which ought to be seen only
during debugging) calls that are being ignored.

Please review this at http://codereview.appspot.com/91116

Affected files:
   features/src/main/javascript/features/rpc/rpc.js


Index: features/src/main/javascript/features/rpc/rpc.js
===================================================================
--- features/src/main/javascript/features/rpc/rpc.js	(revision 794053)
+++ features/src/main/javascript/features/rpc/rpc.js	(working copy)
@@ -85,7 +85,30 @@

    // isGadget =~ isChild for the purposes of rpc (used only in setup).
    var isGadget = (window.top !== window.self);
-  var fallbackTransport = gadgets.rpctx.ifpc;
+
+  // Fallback transport is simply a dummy impl that emits no errors
+  // and logs info on calls it receives, to avoid undesired side-effects
+  // from falling back to IFPC or some other transport.
+  var fallbackTransport = (function() {
+    function logFn(name) {
+      return function() {
+        gadgets.info("gadgets.rpc." + name + "(" +
+                     gadgets.json.stringify(arguments) +
+                     "): call ignored");
+      }
+    }
+    return {
+      getCode: function() {
+        return "noop";
+      },
+      isParentVerifiable: function() {
+        return true;  // Not really, but prevents transport assignment to  
IFPC.
+      },
+      init: logFn("init"),
+      setup: logFn("setup"),
+      call: logFn("call")
+    }
+  })();

    // Load the authentication token for speaking to the container
    // from the gadget's parameters, or default to '0' if not found.