This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require 'ffi' | |
local ip = "127.1.2.3" | |
local p = ffi.cast('const uint8_t *', ip) | |
local ffi_string = ffi.string | |
local tonumber = tonumber | |
local getaddr_ffi = function(ip) | |
local prev = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local record fun | |
record iterator<T> | |
sum: function(iterator<number>): number | |
reduce: function<R>(iterator<T>, (function(R, T): R), R): R | |
end | |
iter: function<T>({T}): iterator<T> | |
sum: function({number}): number | |
reduce: function<T,R>({T}, (function(R,T):R), R): R |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tarantool | |
local uuid = require 'uuid' | |
local fun = require 'fun' | |
local fiber = require 'fiber' | |
local instance_name = assert(arg[1], "instance_name is required") | |
local config = { | |
replication = {'127.0.0.1:3301', '127.0.0.1:3302', '127.0.0.1:3303'}, | |
replication_connect_quorum = 2, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir "$HOME/tarantool"; | |
git clone --recurse-submodules https://github.com/tarantool/tarantool.git && cd tarantool; | |
for tag in $(git tag | sort | perl -lnE '$h{$mj}=$_ if (($mj) = $_=~m{^(1\.10|2\.\d+)\.\d+$});}{say join " ", sort keys %h'); do | |
echo "================== Installing $tag ================"; | |
git clean -xdf .; | |
git checkout "$tag" \ | |
&& git clean -xdf . \ | |
&& git pull origin "$tag" \ | |
&& git reset --hard "origin/$tag" \ | |
&& git submodule update --init --recursive --force \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local type Distance = number | |
local type VertexId = number | |
local record Node | |
preds: {VertexId:Distance} | |
succs: {VertexId:Distance} | |
end | |
local node_mt: metatable<Node> = { | |
__index = Node, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box.orm = require 'orm' . configure { | |
users = { | |
format = { | |
{ name = 'uid', type = 'unsigned' }, | |
{ name = 'email', type = 'string' }, | |
}, | |
indexes = { | |
{ name = 'primary', parts = { 'uid' } }, | |
{ name = 'email', parts = { 'email', 'uid' } }, | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env tarantool | |
print(_G._TARANTOOL) | |
-- box.cfg{} | |
require 'jit.dump'.start("hotloop=1") | |
local fiber = require 'fiber' | |
local log = require 'log' | |
local json = require 'json' | |
json.cfg{ encode_use_tostring = true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
-- TODO: | |
-- Support all ops for update | |
-- Create separate module | |
local ffi = require 'ffi' | |
local fiber = require 'fiber' | |
ffi.cdef[[ | |
struct header_v11 { | |
uint32_t header_crc32c; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local Coro = {} | |
Coro.__index = Coro | |
local S = { | |
queue = require 'q'(), | |
} | |
function S:push(o) | |
self.queue:push(o) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/tarantool | |
local fiber = require 'fiber' | |
local clock = require 'clock' | |
local log = require 'log' | |
local bus = setmetatable({ | |
put = function(self, msg) | |
while not self.closed and self.msg ~= nil do | |
self.cond:wait() |