interface.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>Interface description &#8212; Modelverse 0.4.0 documentation</title>
  7. <link rel="stylesheet" href="_static/classic.css" type="text/css" />
  8. <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  9. <script type="text/javascript">
  10. var DOCUMENTATION_OPTIONS = {
  11. URL_ROOT: './',
  12. VERSION: '0.4.0',
  13. COLLAPSE_INDEX: false,
  14. FILE_SUFFIX: '.html',
  15. HAS_SOURCE: true
  16. };
  17. </script>
  18. <script type="text/javascript" src="_static/jquery.js"></script>
  19. <script type="text/javascript" src="_static/underscore.js"></script>
  20. <script type="text/javascript" src="_static/doctools.js"></script>
  21. <link rel="top" title="Modelverse 0.4.0 documentation" href="index.html" />
  22. <link rel="next" title="Communication models" href="communication_models.html" />
  23. <link rel="prev" title="Internal workings" href="internal.html" />
  24. </head>
  25. <body role="document">
  26. <div class="related" role="navigation" aria-label="related navigation">
  27. <h3>Navigation</h3>
  28. <ul>
  29. <li class="right" style="margin-right: 10px">
  30. <a href="genindex.html" title="General Index"
  31. accesskey="I">index</a></li>
  32. <li class="right" >
  33. <a href="communication_models.html" title="Communication models"
  34. accesskey="N">next</a> |</li>
  35. <li class="right" >
  36. <a href="internal.html" title="Internal workings"
  37. accesskey="P">previous</a> |</li>
  38. <li class="nav-item nav-item-0"><a href="index.html">Modelverse 0.4.0 documentation</a> &#187;</li>
  39. </ul>
  40. </div>
  41. <div class="document">
  42. <div class="documentwrapper">
  43. <div class="bodywrapper">
  44. <div class="body" role="main">
  45. <div class="section" id="interface-description">
  46. <h1>Interface description<a class="headerlink" href="#interface-description" title="Permalink to this headline">¶</a></h1>
  47. <p>All Modelverse components communicate with each other through the use of sockets.
  48. On these sockets, XML/HTTP Requests are used for communication.
  49. In this brief section, we describe the form of these requests.</p>
  50. <div class="section" id="mvs-server">
  51. <h2>MvS server<a class="headerlink" href="#mvs-server" title="Permalink to this headline">¶</a></h2>
  52. <p>The MvS server listens to a fixed set of commands.
  53. All commands have a fully defined signature and result.
  54. Note that commands are encoded: a decoding table is presented below.</p>
  55. <table border="1" class="docutils">
  56. <colgroup>
  57. <col width="15%" />
  58. <col width="85%" />
  59. </colgroup>
  60. <thead valign="bottom">
  61. <tr class="row-odd"><th class="head">Code</th>
  62. <th class="head">Description</th>
  63. </tr>
  64. </thead>
  65. <tbody valign="top">
  66. <tr class="row-even"><td>CN</td>
  67. <td>create_node</td>
  68. </tr>
  69. <tr class="row-odd"><td>CE</td>
  70. <td>create_edge</td>
  71. </tr>
  72. <tr class="row-even"><td>CNV</td>
  73. <td>create_nodevalue</td>
  74. </tr>
  75. <tr class="row-odd"><td>CD</td>
  76. <td>create_dict</td>
  77. </tr>
  78. <tr class="row-even"><td>RV</td>
  79. <td>read_value</td>
  80. </tr>
  81. <tr class="row-odd"><td>RO</td>
  82. <td>read_outgoing</td>
  83. </tr>
  84. <tr class="row-even"><td>RI</td>
  85. <td>read_incoming</td>
  86. </tr>
  87. <tr class="row-odd"><td>RE</td>
  88. <td>read_edge</td>
  89. </tr>
  90. <tr class="row-even"><td>RD</td>
  91. <td>read_dict</td>
  92. </tr>
  93. <tr class="row-odd"><td>RDN</td>
  94. <td>read_dict_node</td>
  95. </tr>
  96. <tr class="row-even"><td>RDNE</td>
  97. <td>read_dict_node_edge</td>
  98. </tr>
  99. <tr class="row-odd"><td>RDE</td>
  100. <td>read_dict_edge</td>
  101. </tr>
  102. <tr class="row-even"><td>RRD</td>
  103. <td>read_reverse_dict</td>
  104. </tr>
  105. <tr class="row-odd"><td>RR</td>
  106. <td>read_root</td>
  107. </tr>
  108. <tr class="row-even"><td>RDK</td>
  109. <td>read_dict_keys</td>
  110. </tr>
  111. <tr class="row-odd"><td>DE</td>
  112. <td>delete_edge</td>
  113. </tr>
  114. <tr class="row-even"><td>DN</td>
  115. <td>delete_node</td>
  116. </tr>
  117. </tbody>
  118. </table>
  119. <p>Requests are sent as POST requests (<em>i.e.</em>, in the data of a HTTP request).
  120. They have the following form:</p>
  121. <div class="highlight-default"><div class="highlight"><pre><span class="n">op</span><span class="o">=</span><span class="n">CODE</span><span class="o">&amp;</span><span class="n">params</span><span class="o">=</span><span class="n">PARAMS</span>
  122. </pre></div>
  123. </div>
  124. <p>In this case, <em>CODE</em> is one of the codes mentioned above, and the value of <em>PARAMS</em> is a JSON encoded list of Modelverse identifiers.
  125. The choice of what is a Modelverse identifier is left to the MvS itself.</p>
  126. <p>The result will be a JSON serialized list containing as first element the response to the request, and as second element the statuscode.
  127. If the statuscode is 200, the first element will be correct.
  128. Otherwise, the statuscode indicates the error, and the first element is set to <em>null</em>.</p>
  129. </div>
  130. <div class="section" id="mvk-server">
  131. <h2>MvK server<a class="headerlink" href="#mvk-server" title="Permalink to this headline">¶</a></h2>
  132. <p>The communication with the MvK is a lot easier, as there is only a very minimal interface: the actual interface needs to be explicitly modelled in action language.
  133. Requests have the following form:</p>
  134. <div class="highlight-default"><div class="highlight"><pre><span class="n">op</span><span class="o">=</span><span class="n">OPERATION</span><span class="o">&amp;</span><span class="n">username</span><span class="o">=</span><span class="n">USERNAME</span><span class="o">&amp;</span><span class="n">value</span><span class="o">=</span><span class="n">VALUE</span>
  135. </pre></div>
  136. </div>
  137. <p>Here, <em>OPERATION</em> defines the operation to execute, of which only two exist:</p>
  138. <ol class="arabic simple">
  139. <li><em>set_input</em>, which adds the sent value to the input queue of the user;</li>
  140. <li><em>get_output</em>, which blocks until there is a value in the output queue of the user.</li>
  141. </ol>
  142. <p>Obviously, <em>USERNAME</em> specifies the name of the user for which the operation needs to happen.</p>
  143. <p>The <em>VALUE</em> is just a JSON encoded value which will be added to the input queue of the Modelverse.
  144. This is ignored when the <em>get_output</em> operation is used.
  145. Note that there are some minor differences between our encoding and JSON encoding.</p>
  146. <p>The supported types are shown below.</p>
  147. <table border="1" class="docutils">
  148. <colgroup>
  149. <col width="27%" />
  150. <col width="73%" />
  151. </colgroup>
  152. <thead valign="bottom">
  153. <tr class="row-odd"><th class="head">Type</th>
  154. <th class="head">Example</th>
  155. </tr>
  156. </thead>
  157. <tbody valign="top">
  158. <tr class="row-even"><td>Integer</td>
  159. <td>1</td>
  160. </tr>
  161. <tr class="row-odd"><td>Float</td>
  162. <td>1.0</td>
  163. </tr>
  164. <tr class="row-even"><td>Boolean</td>
  165. <td>true</td>
  166. </tr>
  167. <tr class="row-odd"><td>String</td>
  168. <td>&#8220;abc&#8221;</td>
  169. </tr>
  170. <tr class="row-even"><td>Action</td>
  171. <td>if</td>
  172. </tr>
  173. </tbody>
  174. </table>
  175. <p>While this list mostly resembles JSON, there are some important differences:</p>
  176. <ul class="simple">
  177. <li>Lists and objects are not supported;</li>
  178. <li>Null object is not supported;</li>
  179. <li>Action type is new, and contains a string representation (without quotes!) of the action language construct to add</li>
  180. </ul>
  181. <p>As response, the <em>set_input</em> will always receive the same reply if the message was correctly deserialized.
  182. Receiving a reply does <em>NOT</em> mean that a message was consumed by the user, it only means that the message was correctly added to the input queue of that user.</p>
  183. <p>A <em>get_output</em> request blocks until a value is available in the users output queue.
  184. The reply to this message will then contain a JSON serialized (with identical remarks as for <em>set_input</em>) containing the value that was output.
  185. Note that now the <em>null</em> message is possible, in case the node that is being outputted does not contain a value (or is an edge).</p>
  186. <div class="section" id="performance-notes">
  187. <h3>Performance notes<a class="headerlink" href="#performance-notes" title="Permalink to this headline">¶</a></h3>
  188. <p>For performance reasons, sending a huge amount of data to the Modelverse (<em>e.g.</em>, a compiled program), should not happen with individual requests for each line.
  189. To allow for packed messages, users can ignore the <em>value</em> parameter, and use the <em>data</em> parameter instead.
  190. The content of this parameter should be a JSON encoded list of all individual values to be inserted.</p>
  191. </div>
  192. </div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
  198. <div class="sphinxsidebarwrapper">
  199. <h3><a href="index.html">Table Of Contents</a></h3>
  200. <ul>
  201. <li><a class="reference internal" href="#">Interface description</a><ul>
  202. <li><a class="reference internal" href="#mvs-server">MvS server</a></li>
  203. <li><a class="reference internal" href="#mvk-server">MvK server</a><ul>
  204. <li><a class="reference internal" href="#performance-notes">Performance notes</a></li>
  205. </ul>
  206. </li>
  207. </ul>
  208. </li>
  209. </ul>
  210. <h4>Previous topic</h4>
  211. <p class="topless"><a href="internal.html"
  212. title="previous chapter">Internal workings</a></p>
  213. <h4>Next topic</h4>
  214. <p class="topless"><a href="communication_models.html"
  215. title="next chapter">Communication models</a></p>
  216. <div role="note" aria-label="source link">
  217. <h3>This Page</h3>
  218. <ul class="this-page-menu">
  219. <li><a href="_sources/interface.txt"
  220. rel="nofollow">Show Source</a></li>
  221. </ul>
  222. </div>
  223. <div id="searchbox" style="display: none" role="search">
  224. <h3>Quick search</h3>
  225. <form class="search" action="search.html" method="get">
  226. <div><input type="text" name="q" /></div>
  227. <div><input type="submit" value="Go" /></div>
  228. <input type="hidden" name="check_keywords" value="yes" />
  229. <input type="hidden" name="area" value="default" />
  230. </form>
  231. </div>
  232. <script type="text/javascript">$('#searchbox').show(0);</script>
  233. </div>
  234. </div>
  235. <div class="clearer"></div>
  236. </div>
  237. <div class="related" role="navigation" aria-label="related navigation">
  238. <h3>Navigation</h3>
  239. <ul>
  240. <li class="right" style="margin-right: 10px">
  241. <a href="genindex.html" title="General Index"
  242. >index</a></li>
  243. <li class="right" >
  244. <a href="communication_models.html" title="Communication models"
  245. >next</a> |</li>
  246. <li class="right" >
  247. <a href="internal.html" title="Internal workings"
  248. >previous</a> |</li>
  249. <li class="nav-item nav-item-0"><a href="index.html">Modelverse 0.4.0 documentation</a> &#187;</li>
  250. </ul>
  251. </div>
  252. <div class="footer" role="contentinfo">
  253. &#169; Copyright 2016, Yentl Van Tendeloo.
  254. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.6.
  255. </div>
  256. </body>
  257. </html>