maxim-komar / cartridge-and-vshard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Tarantool Cartridge-based application

This a simplest application based on Tarantool Cartridge.

Quick start

To build application and setup topology:

cartridge build
cartridge start -d
cartridge replicasets setup --bootstrap-vshard

Now you can visit http://localhost:8081 and see your application's Admin Web UI.

Note, that application stateboard is always started by default. See .cartridge.yml file to change this behavior.

Application

Application entry point is init.lua file. It configures Cartridge, initializes admin functions and exposes metrics endpoints. Before requiring cartridge module package_compat.cfg() is called. It configures package search path to correctly start application on production (e.g. using systemd).

Roles

Application has one simple role, app.roles.custom. It exposes /hello and /metrics endpoints:

curl localhost:8081/hello
curl localhost:8081/metrics

Also, Cartridge roles are registered (vshard-storage, vshard-router and metrics).

You can add your own role, but don't forget to register in using cartridge.cfg call.

Instances configuration

Configuration of instances that can be used to start application locally is places in instances.yml. It is used by cartridge start.

Topology configuration

Topology configuration is described in replicasets.yml. It is used by cartridge replicasets setup.

Tests

Simple unit and integration tests are placed in test directory.

First, we need to install test dependencies:

./deps.sh

Then, run linter:

.rocks/bin/luacheck .

Now we can run tests:

cartridge stop  # to prevent "address already in use" error
.rocks/bin/luatest -v

Admin

Application has admin function probe configured. You can use it to probe instances:

cartridge start -d  # if you've stopped instances
cartridge admin probe \
  --name cartridge-and-vshard \
  --run-dir ./tmp/run \
  --uri localhost:3302

About


Languages

Language:Lua 93.1%Language:Shell 4.6%Language:Makefile 2.3%