-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align with JSON-RPC? #4
Comments
Not a bad idea. On Sun, Dec 2, 2012 at 1:19 AM, Tom Robinson [email protected]:
Jeff Lindsay |
I approve. It's also a bit easier to explain to developers as "Federated RPC". The id field is nice since it essentially behaves as a token/key which is useful in cases where a Block needs to handle state. |
I don't think the JSON-RPC id field is useful for tracking state since it's On Dec 2, 2012, at 9:42 AM, Matthew Hudson [email protected] wrote: I approve. It's also a bit easier to explain to developers as "Federated The id field is nice since it essentially behaves as a token/key which is — |
Headers. Either HTTP or if new JSON-RPC supports some kind of headers. On Sun, Dec 2, 2012 at 9:45 AM, Tom Robinson [email protected]:
Jeff Lindsay |
A database Block perfectly illustrates the value of a "methods" key in the Block Definition.
To accomodate this new Block Definition format, a HTTP request would change in the following ways:
Thoughts? |
Or, if we went full JSON-RPC:
Using the database Block Definition I mentioned in my last post, this example would return a record for a given database key. |
Including a method name in the request body is very un-RESTful, but then again what we have so far isn't exactly RESTful either (and JSON-RPC definitely isn't either). It would be nice if we could just use GET methods to enable caching, etc, but GET requests don't have a request body for us to include the inputs. Inputs could be mapped to the query string (or even include the JSON in the URL). The HTTP methods could be mapped to the Also we definitely shouldn't use JSON-RPC 1.0 positional arguments. JSON-RPC 2.0 supports named arguments. |
I'm sorry, I wasn't as clear as I could have been with my database example. We aren't passing a HTTP Method as an argument, we're passing the name of the "remote procedure" we want to run. In JSON-RPC, the "method" is the remote procedure you want to invoke. In my example, the database block exposed two methods/functions/remote procedures - 'get' and 'set'. 'Get' would return a database record, and 'set' would save a database record. As for REST, we're pretty much eschewing HTTP all together if we decide to go multi-protocol. That makes the following things irrelevant:
|
I feel like maybe aligning with JSON-RPC is getting a little out of hand. On Sun, Dec 9, 2012 at 8:05 PM, Matthew Hudson [email protected]:
Jeff Lindsay |
I have to agree with Jeff. I think we ought to leverage JSON-RPC only for inspiration, not total adoption. Like Jeff said, we agreed to focus on HTTP. I think the two biggest inspirations we gain from JSON-RPC are:
|
Why can't a database block be split into different blocks? On Sun, Dec 9, 2012 at 8:34 PM, Matthew Hudson [email protected]:
Jeff Lindsay |
Wouldn't that be confusing? How would a block specify a relationship with one or more other blocks? |
I don't know what you mean. Give me an example. On Sun, Dec 9, 2012 at 8:56 PM, Matthew Hudson [email protected]:
Jeff Lindsay |
So, I'm proposing we adopt the "methods" key from JSON-RPC so that a single block can expose multiple functions. This new "methods" key would map method names to our inputs/outputs. Here's an example:
You seem to be proposing that we don't need to allow blocks to expose multiple methods and that my example database block should instead be two separate blocks, like this: Save Record:
Retrieve Record:
So my question to you is this: how does "database-set-record" describe its relationship with "database-get-record" and vice-versa? How does an enduser who knows about one of these block know about the other? |
Naming convention? Meta-data? Maybe that's a registry/index problem? There was an operating system called Genera. It was 100% LISP. Think about In fact, think of Unix today. There are lots of system calls with related Anyway, I'm getting too far from the point. I think the point is that the What do you call a block with multiple functions? An aggregate block? Wait -jeff On Sun, Dec 9, 2012 at 9:09 PM, Matthew Hudson [email protected]:
Jeff Lindsay |
I agree the JSON-RPC thing might be too complicated, but I think we should commit to something that's RPC-like or REST-like, but not halfway in between. Personally I favor REST. If we go REST it might make sense to have the "methods" key in the OPTIONs response map to HTTP methods, so we can do GET, POST, PUT, DELETE on the same endpoint. But I don't like having arbitrary methods like "set" in there. This is sort of why I was interested in working on Skylib concurrently with WebPipes. If we had a generic way to document REST APIs in a machine readable way then WebPipes APIs would just be a slightly constrained subset of Skylib APIs (a "flat" map of inputs in the request, either as a JSON object or maybe query string parameters, or even XML, and a flat output object, or array of objects. Or maybe they don't even need to be flat objects, but that complicates things). |
I was never suggesting implementing a new HTTP Method called "set", or mapping HTTP Methods to an OPTIONS key called 'methods'. I was proposing we nest our input/output arguments inside something like the JSON-RPC request object member called 'method'. Here's an example of how the Block Definition would change:
Jeff argued against that idea and I'm slowly coming around to his way of thinking. |
Yeah, I understood that completely and didn't mean to suggest otherwise, but including any kind of method name in either the request body (as you're suggesting) or in the URL (even as a separate endpoint for the same "resource", as Jeff is suggesting) is more "RPCful" than RESTful. If we want to be RESTful I am proposing mapping different HTTP method names in the OPTIONs request. If we want to be RPCful then why not just use JSON-RPC over HTTP? But I'd rather be RESTful. |
BTW, WADL looks a lot like what I'm proposing, but it's XML :( Here's an example: http://www.w3.org/Submission/wadl/#x3-40001.3 |
I think Matt mentioned this early on: what we have is fairly close to JSON-RPC. Maybe it's worth making it compatible?
JSON-RPC 1.0 uses an array of arguments, but 2.0 supports named parameters, so it would be almost identical to what we have (rename
inputs
toparams
,outputs
toresult
).One nice thing about using JSON-RPC is we could potentially expose WebPipes over more efficient transports like TCP sockets/WebSockets/ZeroMQ. When using HTTP we could drop the id and method field (since the "method" is in the URL). When using a socket, the method would just be the url or path, and id would be used to pair the response with the request.
The text was updated successfully, but these errors were encountered: