forked from avral/golosnotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.lua
110 lines (93 loc) · 3.09 KB
/
app.lua
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
fiber = require 'fiber'
clock = require 'clock'
json = require('json')
require 'counters'
require 'queues'
require 'locks'
require 'stats'
require 'subscriptions'
require 'group_queues'
io.output():setvbuf("no")
box.cfg {
log_level = 5,
listen = '0.0.0.0:3302',
memtx_memory = 1 * 1024*1024*1024,
wal_dir = "/var/lib/tarantool",
memtx_dir = "/var/lib/tarantool",
vinyl_dir = "/var/lib/tarantool"
}
box.once('bootstrap', function()
print('initializing..')
box.schema.user.grant('guest', 'read,write,execute,create,drop,alter ', 'universe')
box.session.su('guest')
steem = box.schema.create_space('steem')
steem:create_index('primary', {type = 'tree', parts = {1, 'STR'}})
counters = box.schema.create_space('counters')
counters:create_index('primary', {type = 'tree', parts = {1, 'STR'}})
queues = box.schema.create_space('queues')
queues:create_index('primary', {
type = 'tree', parts = {1, 'unsigned'}
})
queues:create_index('by_acc_subscriber', {
type = 'tree', parts = {2, 'STR', 1, 'unsigned'}
})
queues:create_index('by_update', {
type = 'tree', parts = {4, 'unsigned'}, unique = false
})
locks = box.schema.create_space('locks')
locks:create_index('primary', {type = 'tree', parts = {1, 'STR'}})
-- subs spaces
subs = box.schema.create_space('subs')
subs:create_index('primary', {
type = 'tree', parts = {1, 'unsigned'}
})
subs:create_index('by_subscriber_date', {
type = 'tree', parts = {2, 'STR', 5, 'unsigned'}, unique = false
})
subs:create_index('by_subscriber_events', {
type = 'tree', parts = {2, 'STR', 6, 'unsigned'}, unique = false
})
subs:create_index('by_entity_id_subscriber', {
type = 'tree', parts = {4, 'STR', 2, 'STR'}
})
events = box.schema.create_space('events')
events:create_index('primary', {
type = 'tree', parts = {1, 'unsigned'}
})
events:create_index('by_entity_id_subscriber', {
type = 'tree', parts = {4, 'STR', 2, 'STR'}, unique = false
})
-- stats spaces
viewables = box.schema.create_space('viewables')
viewables:create_index('primary', {
type = 'tree', parts = {1, 'unsigned'}
})
viewables:create_index('by_hash', {
type = 'tree', parts = {2, 'unsigned'}
})
viewables:create_index('by_date', {
type = 'tree', parts = {3, 'unsigned'}, unique = false
})
views = box.schema.create_space('views')
views:create_index('primary', {
type = 'tree', parts = {1, 'unsigned'}
})
views:create_index('by_hash_ip', {
type = 'tree', parts = {2, 'unsigned', 3, 'STR'}
})
views:create_index('by_date', {
type = 'tree', parts = {4, 'unsigned'}, unique = false
})
end)
migrate_subs()
migrate_group_queues()
function send_json(req, table)
local resp = req:render({text = json.encode(table)})
resp.headers['content-type'] = 'application/json'
resp.status = 200
return resp
end
function root_handler(req)
return send_json(req, {status = 'ok'})
end
-- require('console').start()