Scripts.coffee
3.59 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
lua = require "./lua.json"
headers =
refs: lua["refs.lua"]
validate_keys: lua["validate_keys.lua"]
validate_client: lua["validate_client.lua"]
refresh_expiration: lua["refresh_expiration.lua"]
process_tick: lua["process_tick.lua"]
conditions_check: lua["conditions_check.lua"]
get_time: lua["get_time.lua"]
exports.allKeys = (id) -> [
###
HASH
###
"b_#{id}_settings"
###
HASH
job index -> weight
###
"b_#{id}_job_weights"
###
ZSET
job index -> expiration
###
"b_#{id}_job_expirations"
###
HASH
job index -> client
###
"b_#{id}_job_clients"
###
ZSET
client -> sum running
###
"b_#{id}_client_running"
###
HASH
client -> num queued
###
"b_#{id}_client_num_queued"
###
ZSET
client -> last job registered
###
"b_#{id}_client_last_registered"
###
ZSET
client -> last seen
###
"b_#{id}_client_last_seen"
]
templates =
init:
keys: exports.allKeys
headers: ["process_tick"]
refresh_expiration: true
code: lua["init.lua"]
group_check:
keys: exports.allKeys
headers: []
refresh_expiration: false
code: lua["group_check.lua"]
register_client:
keys: exports.allKeys
headers: ["validate_keys"]
refresh_expiration: false
code: lua["register_client.lua"]
blacklist_client:
keys: exports.allKeys
headers: ["validate_keys", "validate_client"]
refresh_expiration: false
code: lua["blacklist_client.lua"]
heartbeat:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: false
code: lua["heartbeat.lua"]
update_settings:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: true
code: lua["update_settings.lua"]
running:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: false
code: lua["running.lua"]
queued:
keys: exports.allKeys
headers: ["validate_keys", "validate_client"]
refresh_expiration: false
code: lua["queued.lua"]
done:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: false
code: lua["done.lua"]
check:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"]
refresh_expiration: false
code: lua["check.lua"]
submit:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"]
refresh_expiration: true
code: lua["submit.lua"]
register:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick", "conditions_check"]
refresh_expiration: true
code: lua["register.lua"]
free:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: true
code: lua["free.lua"]
current_reservoir:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: false
code: lua["current_reservoir.lua"]
increment_reservoir:
keys: exports.allKeys
headers: ["validate_keys", "validate_client", "process_tick"]
refresh_expiration: true
code: lua["increment_reservoir.lua"]
exports.names = Object.keys templates
exports.keys = (name, id) ->
templates[name].keys id
exports.payload = (name) ->
template = templates[name]
Array::concat(
headers.refs,
template.headers.map((h) -> headers[h]),
(if template.refresh_expiration then headers.refresh_expiration else ""),
template.code
)
.join("\n")