-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinit.lua
More file actions
53 lines (45 loc) · 1.31 KB
/
init.lua
File metadata and controls
53 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
box.cfg{
-- listen = '127.0.0.1:4221'
}
-- box.once('access:v1', function()
-- box.schema.user.grant('guest', 'read,write,execute', 'universe')
-- end)
require 'strict'.on()
-- box.once('schema',function()
local format = {
{name = "id", type = "string"},
{name = "status", type = "string"},
{name = "runat", type = "number"},
{name = "attempt", type = "number"},
{name = "action", type = "string"},
{name = "attr", type = "*"},
}
box.schema.space.create('tasks', { if_not_exists = true })
box.space.tasks:create_index('primary', { unique = true, parts = {1, 'string'}, if_not_exists = true})
box.space.tasks:create_index('xq', { unique = false, parts = { 2, 'str', 1, 'string' }, if_not_exists = true})
box.space.tasks:create_index('run', { unique = true, parts = { 3, 'number', 1, 'string' }, if_not_exists = true})
-- end)
if not package.path:match('%.%./%?%.lua;') then
package.path = '../?.lua;' .. package.path
end
require 'xqueue' ( box.space.tasks, {
debug = true;
format = format;
fields = {
status = 'status';
runat = 'runat';
};
features = {
id = 'uuid',
delayed = true,
};
workers = 1;
worker = function(task)
print("got task",task)
end;
} )
for i = 1, 100 do
box.space.tasks:put{ attempt = 0, action = "doit", attr = {} }
end
require'console'.start()
os.exit()