Tarantool code examples
doc/code_snippets folder of a Tarantool documentation repository contains runnable code examples that show how to work with Tarantool:
- The snippets folder contains sample applications that demonstrate how to configure a Tarantool cluster.
- The test folder contains testable Lua examples that show how to work with various Tarantool modules.
Code from these examples is referenced in corresponding documentation sections.
To run applications placed in snippets, follow these steps:
Go to the directory containing samples for a specific feature, for example, snippets/replication.
To run applications placed in instances.enabled, execute the
tt startcommand, for example:
$ tt start auto_leader
To test all the examples, go to the
doc/code_snippets folder and execute the
To test the examples from the specified directory, pass its relative path to the
To test a specific example with the
stdout output enabled, use the
luatest command with the
-c option, for example:
.rocks/bin/luatest -c test/http_client/get_test.lua
Note that the HTTP client samples (placed in
test/http_client) use the
You can run
httpbin locally using Docker to stabilize test results:
docker run -p 80:80 kennethreitz/httpbin
In this case, you need to replace
https://httpbin.org links with
To display a specific source file in a topic, use the
literalinclude directive as follows:
.. literalinclude:: /code_snippets/test/http_client/post_json_test.lua