Multiple methods

8 views
Skip to first unread message

Justin Meyer

unread,
Nov 12, 2009, 6:40:53 PM11/12/09
to JSON-RPC
I'm just reading up on this. I like what I see, but forgive me if I
ask an ignorant question. I am making an ftp service that allows you
to call services on ruby's net/ftp:

http://ruby-doc.org/stdlib/libdoc/net/ftp/rdoc/classes/Net/FTP.html

But, with ftp, you often want to do a few operations at once. This is
why I am doing something like:

[
{
method: "voidcmd",
params: ["CWD "+( params.path || "/")]
},
{
method: "list",
result: "files"
}
]

This will effectively run:

ftp.voidcmd("CWD /")
ftp.list()

and return:

{files: " ... the result of ftp.list() ....", error: null}

Is there anything for this type of multiple method call?

Matt (MPCM)

unread,
Nov 16, 2009, 10:10:05 AM11/16/09
to JSON-RPC
The 2.0 spec support batch calls, which pretty much look like your
example. However, there is no guarantee of order or that they run one
at a time...

So you probably want to expose a single method which takes an array as
a parameter, an array of ftp commands in your case, to run in order.
This should also allow do your own smarter error handling and
optimizing, and then you focus on documenting your function and the
parameters it takes.

--
Matt (MPCM)
Reply all
Reply to author
Forward
0 new messages