ironthree / dxr

Declarative XML-RPC in Rust
Apache License 2.0
17 stars 8 forks source link

Support system.multicall #13

Closed bahlo closed 1 year ago

bahlo commented 1 year ago

Hi, it's me again. Would you accept a PR that adds support for the system.multicall extension?

If yes, any hints/thoughts for the impl?

decathorpe commented 1 year ago

I've never used multicall support, so I don't even know how it's supposed to work. Is it documented somewhere? I can only find references to an RFC in the wayback machine / Internet Archive ... (but I do see that Python and Java XML-RPC libraries do implement this).

decathorpe commented 1 year ago

This is the only documentation I can find, other than actual implementations of system.multicall:

https://web.archive.org/web/20060624230303/http://www.xmlrpc.com/discuss/msgReader$1208?mode=topic

As far as I can tell, implementing this on the client side should be quite straightforward.

decathorpe commented 1 year ago

Ok, I've pushed an initial draft implementation for multicall support: https://github.com/ironthree/dxr/commit/24af6dbf77da4ffa336ffc5bb362d55368898285

I don't really have a way to test this (yet), so please let me know what you think.

bahlo commented 1 year ago

Hi, this looks good to me, I need this on the server side (sorry I missed that little detail). Here's an example request I'm getting in:

<?xml version="1.0" encoding="iso-8859-1"?>
<methodCall>
  <methodName>system.multicall</methodName>
  <params>
    <param>
      <value>
        <array>
          <data>
            <value>
              <struct>
                <member>
                  <name>methodName</name>
                  <value>event</value>
                </member>
                <member>
                  <name>params</name>
                  <value>
                    <array>
                      <data>
                        <value>foo</value>
                        <value>bar</value>
                        <value>baz</value>
                        <value><boolean>1</boolean></value>
                      </data>
                    </array>
                  </value>
                </member>
              </struct>
            </value>
            <value>
              <struct>
                <member>
                  <name>methodName</name>
                  <value>event</value>
                </member>
                <member>
                  <name>params</name>
                  <value>
                    <array>
                      <data>
                        <value>another</value>
                        <value>call</value>
                        <value>hi</value>
                        <value><boolean>1</boolean></value>
                      </data>
                    </array>
                  </value>
                </member>
              </struct>
            </value>
          </data>
        </array>
      </value>
    </param>
  </params>
</methodCall>
decathorpe commented 1 year ago

Well, having it in both client and server at least means I was able to add self-contained tests for this 🤣

It would be great if you could take a look here: https://github.com/ironthree/dxr/commit/72ed48961199da45e4bae472060ab7de09dbe291

TL;DR: Enable the multicall feature in the dxr_server crate, and it should hopefully just "do the right thing ™️ ".

bahlo commented 1 year ago

This looks great, will check it out and let you know 🙌🏻

decathorpe commented 1 year ago

I've tested the server support by making multicall calls from Python, and everything seems to work as expected.

bahlo commented 1 year ago

Hi @decathorpe, sorry for not following up, didn't find the time yet

decathorpe commented 1 year ago

No problem! As far as I can tell it works as expected. Just let me know if I missed something.

bahlo commented 1 year ago

works great 🙏