diff --git a/doc/user/configuration-reference.xml b/doc/user/configuration-reference.xml index 9312b57ebbe9da202fbc7ec683d25d72849b8c4f..2a11916b04f23becf89f8748d88d495d444c4ab3 100644 --- a/doc/user/configuration-reference.xml +++ b/doc/user/configuration-reference.xml @@ -204,10 +204,10 @@ box.cfg{ </row> <row> <entry xml:id="primary_port" xreflabel="primary_port">primary_port</entry> - <entry>integer</entry> + <entry>integer or string</entry> <entry>null</entry> <entry>no</entry> - <entry>The read/write data port. + <entry>The read/write data port number or URI (Universal Resource Identifier) string. Has no default value, so <emphasis role="strong">must be specified</emphasis> if connections will occur from remote clients @@ -220,15 +220,16 @@ box.cfg{ <row> <entry xml:id="admin_port" xreflabel="admin_port">admin_port</entry> - <entry>integer</entry> + <entry>integer or string</entry> <entry>null</entry> <entry>no</entry> - <entry>The port to listen on for administrative + <entry>The port or URI to listen on for administrative connections. Has no default value, so must be specified if connections will occur via telnet. Not used unless assigned a value. This may be expressed with URI = Universal Resource Identifier format, for example "unix://unix_domain_socket", - or as a numeric TCP port. A typical value is 3313.</entry> + or as a numeric TCP port. Connections are often made with telnet. + A typical value is 3313.</entry> </row> <row> diff --git a/doc/user/connectors.xml b/doc/user/connectors.xml index dfeee3ad7dcaa568115414df162f940a9bc337ef..2421dfaf693d391a136c7cae676c4b706a9eb23d 100644 --- a/doc/user/connectors.xml +++ b/doc/user/connectors.xml @@ -335,27 +335,34 @@ catch (Exception $e) { <section xml:id="connector-python"> <title>Python</title> <para> - Here is a complete Python program that inserts [99999,'BB'] into space[0] via the high-level Python API. + Here is a complete Python program that inserts ['First Tuple','Value','Value'] into space99 via the high-level Python API. To prepare, paste the code into a file named example.py and install tarantool-python with either <userinput><code>pip install tarantool</code></userinput> to install in <filename>/usr</filename> (requires root privilege) or <userinput><code>pip install tarantool --user</code></userinput> to install in <filename>~</filename> i.e. user's default directory. - Before trying to run, check that the server (tarantool) is running on localhost (127.0.0.1) and its primary port - is the default (3303) and space[0]'s primary key type is string (space[0].index[0].key_field[1].type = "STR" in configuration file). - To run, say <code>python example.py</code>. + The program is assuming that the server (tarantool) is running on localhost (127.0.0.1) and its primary port is + the default (3303) and space99's primary key type is string (box.space.space99.index['primary'].key_field[1].type = "STR") + and user 'guest' has permission to read and write on space99. An administrator could fulfill all those conditions by + starting the tarantool server and executing these requests:<programlisting> +box.cfg{primary_port = 3303} +box.schema.create_space('space99') +box.space.space99:create_index('primary',{parts = {1,'STR'}}) +box.schema.user.grant('guest', 'read', 'space', '_space') +box.schema.user.grant('guest', 'read,write', 'space', 'space99')</programlisting> + To run the program, say <code>python example.py</code>. The program will connect to the server, will send the request, and will not throw an exception if all went well. - If the row already exists, the program will throw DatabaseException(“Duplicate key exists in unique index 0â€). + If the tuple already exists, the program will throw DatabaseException(“Duplicate key exists in unique indexâ€). </para> <programlisting language="python"> #!/usr/bin/python from tarantool import Connection c = Connection("127.0.0.1", 3303) -result = c.insert(0,(99999,'BB')) +result = c.insert("space99",('First Tuple','Value', 'Value')) print result </programlisting> <para> - The example program only shows one command and does not show all that's necessary for + The example program only shows one request and does not show all that's necessary for good practice. For that, please see <link xlink:href="http://tarantool-python.readthedocs.org/en/latest/"><filename>http://tarantool-python.readthedocs.org/en/latest/</filename></link>. For an example of a Python API for <link xlink:href="https://github.com/tarantool/queue">Queue managers on Tarantool</link>, see diff --git a/doc/user/databases.xml b/doc/user/databases.xml index d834f64e9f17e828d57ffcbfd1aafeab90faa6a7..391c69220912934f0039a0ed96403eb5d63e18c3 100644 --- a/doc/user/databases.xml +++ b/doc/user/databases.xml @@ -1199,17 +1199,17 @@ tarantool> <userinput>box.space.space0:auto_increment{'Fld#3'}</userinput> Complexity Factors: Index size, Index type, WAL settings. </para> <bridgehead renderas="sect4">Example</bridgehead> -<programlisting>tarantool> <userinput>s = box.schema.create_space('space18')</userinput> +<programlisting>tarantool> <userinput>s = box.schema.create_space('forty_second_space')</userinput> --- ... tarantool> <userinput>s:create_index('primary', {unique = true, parts = {1, 'NUM', 2, 'STR'}})</userinput> --- ... -tarantool> <userinput>box.space.space18:inc{1,'a'}</userinput> +tarantool> <userinput>box.space.forty_second_space:inc{1,'a'}</userinput> --- - 1 ... -tarantool> <userinput>box.space.space18:inc{1,'a'}</userinput> +tarantool> <userinput>box.space.forty_second_space:inc{1,'a'}</userinput> --- - 2 ...</programlisting> @@ -2785,23 +2785,11 @@ Otherwise, use the box.net.box package to pass the function to the host and port </variablelist> </section> -<section xml:id="administrative-console"> - <title>Administrative console</title> - <para> - The administrative console is simply an outlet of the Tarantool - Lua interpreter. You can connect to the administrative port - using any <command>telnet</command> client, or a tool like - <command>rlwrap</command>, if access to readline features is - desired. Additionally, <command>tarantool</command>, the - command line client, may distinguish between requests types - and direct them to the appropriate port. - The server response to an administrative command, even though - it is always in plain text, can be quite complex. - It is encoded using YAML markup to simplify automated parsing. - </para> +<section xml:id="administrative-requests"> + <title>Administrative requests</title> <para>To learn which functions are considered to be administrative, - type <emphasis role="lua">help()</emphasis> in the - administrative console. A reference description also follows + type <emphasis role="lua">help()</emphasis>. + A reference description also follows below:</para> <variablelist> diff --git a/doc/user/lua-and-packages.xml b/doc/user/lua-and-packages.xml index 182f14d3e5274ad30acd37c80941ef2cb65f825f..c73a832cb9ae61f6ba5714aa634f2ffcdd4a192e 100644 --- a/doc/user/lua-and-packages.xml +++ b/doc/user/lua-and-packages.xml @@ -123,9 +123,9 @@ connection. Just as a sampling: ... <link xlink:href="https://rocks.moonscript.org/modules/kikito/i18n">i18n</link> an internationalization library, <link xlink:href="https://rocks.moonscript.org/modules/luarocks/lposix">lposix</link> a POSIX library, <link xlink:href="https://rocks.moonscript.org/modules/luarocks/lua-spore">lua-Spore</link> a generic ReST client, -<link xlink:href="https://rocks.moonscript.org/modules/luarocks/tekui">TekUI</link> a GUI toolkit . -Examples exist for how to bring in particular downloadable packages after -starting Tarantool. +<link xlink:href="https://rocks.moonscript.org/modules/luarocks/tekui">TekUI</link> a GUI toolkit. +For example, to bring in the i18n package: install luarocks, say <code>luarocks install i18n</code>, +start Tarantool, and say <code>require('i18n')</code>. </para> <para> diff --git a/doc/user/server-administration.xml b/doc/user/server-administration.xml index ba3b278a3e9790049022ea198da5e0bd127c64dd..a0062a218ad69915921a9f27c19854ea94de36c1 100644 --- a/doc/user/server-administration.xml +++ b/doc/user/server-administration.xml @@ -514,6 +514,25 @@ purposes are: session.user() #returns the name of the current user session.su(<replaceable>user-name</replaceable>) #allows changing current user to 'user-name'</programlisting></para> +<para> +If a user types requests directly on the Tarantool server in its interactive mode, +or if a user connects via telnet to the administrative port (using +<olink targetptr="admin_port"/> instead of primary_port), then the user by default is 'admin' and has +many privileges. If a user connects from an application program via one of the +<olink targetptr="connectors">connectors</olink>, then the user by default is 'guest' and has few +privileges. Typically an admin user will set up and configure objects, then +grant privileges to appropriate non-admin users. Typically a guest user will +use <code>session.su()</code> to change into a non-generic user to whom admin +has granted more than the default privileges. For example, admin might say:<programlisting> +box.space._user:insert{123456,'','manager'} +box.schema.user.grant('manager', 'read', 'space', '_space') +box.schema.user.grant('manager', 'read', 'space', 'payroll')</programlisting> +and later a guest user, who wishes to see the payroll, might say:<programlisting> +session = require('session') +session.su('manager') +box.space.payroll:select{'Jones'}</programlisting> +</para> + </section> </chapter> diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml index 5e45011d0398e92c1fa5f8317c111b480ef751d8..244e23baed30ae377306a56fa2302a9c6e10a0ab 100644 --- a/doc/user/stored-procedures.xml +++ b/doc/user/stored-procedures.xml @@ -1460,9 +1460,8 @@ for instructions about defining triggers for connect and disconnect events a long time. </para> <para> - As with all other <code>box</code> functions, the API can be used - in procedural style (e.g. <code>socket.close(socket)</code>) as well - as in object-oriented style (<code>socket:close()</code>). + Most of the functions in the API are usually used + in object-oriented style, for example <code>socket:close()</code>. </para> <para> A closed socket should not be used any more. Alternatively, the @@ -1726,6 +1725,18 @@ for instructions about defining triggers for connect and disconnect events </para> </listitem> </varlistentry> + + <varlistentry> + <term><emphasis role="lua">socket:setsockopt()</emphasis> etc.</term> + <listitem> + <para> + For examples of functions not listed here -- including setsockopt, + getsockopt, accept, wait, writable, and all the less-used functions -- + see the files bsdsocket.test.lua and socket.test.py which are supplied + as part of the Tarantool source. + </para> + </listitem> + </varlistentry> </variablelist>