Skip to content

Instantly share code, notes, and snippets.

@R-omk
R-omk / tnteval
Created January 24, 2020 06:56
Print output from tarantool to stdout
#!/usr/bin/env tarantool
local CONSOLE_SOCKET_PATH = 'unix/:/var/run/tarantool/tarantool.sock'
local os = require("os")
console = require('console')
console.on_start(function(self)
local status, reason
status, reason = pcall(function() require('console').connect(CONSOLE_SOCKET_PATH) end)
if not status then
@R-omk
R-omk / app.js
Created May 24, 2019 08:55
incognito external redirect
const getLink = node => {
if (!node) {
return undefined
}
return node.href ? node : getLink(node.parentNode)
}
const onClick = e => {
@R-omk
R-omk / Makefile
Created April 15, 2019 07:21
tarantool Segmentation fault transaction
CLEAN:
docker-compose down -v
START:
docker-compose up
RUN: CLEAN START
@R-omk
R-omk / app.lua
Created October 4, 2018 11:56
docker swarm tarantool test cluster
-- other options setup in tarantool-entrypoint.lua see: https://github.com/tarantool/docker
box.cfg {
log_level = tonumber(os.getenv("TARANTOOL_LOG_LEVEL"));
replicaset_uuid = os.getenv("TARANTOOL_REPLICASET_UUID");
instance_uuid = os.getenv("TARANTOOL_INSTANCE_UUID");
memtx_max_tuple_size = 1048576 + 200;
force_recovery = true;
checkpoint_interval = 30;
checkpoint_count = 3;
}
@R-omk
R-omk / some_tarantool_queue.lua
Last active December 26, 2016 20:42
queue long polling tarantool example
-- schema: key, group, weight, status, time
box.schema.space.create(rehab_space, { if_not_exists = true, temporary = true })
box.space[rehab_space]:create_index('primary', { type = 'TREE', unique = true, parts = { 1, 'string' }, if_not_exists = true })
box.space[rehab_space]:create_index('group', { type = 'TREE', unique = false, parts = { 2, 'unsigned', 4, 'unsigned', 3, 'unsigned' }, if_not_exists = true })
box.space[rehab_space]:create_index('time', { type = 'TREE', unique = false, parts = { 5, 'number' }, if_not_exists = true })
-----------------
local function rehab_release(key)
this.spaces.boxrehab:delete({ key })
end
@R-omk
R-omk / test.lua
Created December 23, 2016 08:35
tarantool memory eviction issue
local log_level = 5
box.cfg {
username = nil;
work_dir = nil;
wal_dir = "/tmp";
snap_dir = "/tmp";
vinyl_dir = "/tmp";
listen = 3301;
@R-omk
R-omk / bloomfilter_concept_example.lua
Last active August 27, 2019 09:33
tarantool bloomfilter concept
local bloom = require('bloomfilter')
local bloom_options = {size = 512, hash = 3}
local bf_instance = bloom.new(bloom_options)
local init_state = nil
local somedata = "Data"
local somedata2 = "Data2"
-- now the filter is filled with zeros
@R-omk
R-omk / main.go
Last active October 21, 2019 05:24
golang redis memcached performance rps test
package main
import (
"log"
"time"
"github.com/garyburd/redigo/redis"
"github.com/youtube/vitess/go/pools"
"golang.org/x/net/context"
"sync"
@R-omk
R-omk / get.c
Last active November 3, 2016 16:15
tarantool get c function, get tuple with selected fields only remote:call('get' , 'spacename', fieldbitMask, 'key1')
#include "module.h"
#include "msgpuck.h"
int get(box_function_ctx_t *ctx, const char *args, const char *args_end) {
// primary index is 0
uint32_t index_id = 0;
uint32_t arg_count = mp_decode_array(&args);
@R-omk
R-omk / remote-multi-call-example.lua
Last active January 22, 2016 15:31
tarantool remote multiplexing call example
box.cfg {
username = nil;
work_dir = nil;
wal_dir = ".";
snap_dir = ".";
sophia_dir = ".";
listen = 3307;
pid_file = "example.pid";
background = true;