-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
83 lines (60 loc) · 1.79 KB
/
index.js
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
const { createCache } = require('./utils/interval-cache-store')
function batchKeys ({ key, option, path, time }) {
const interval = 1000 * (time || 60)
const result = createCache(`batch-keys-${key}`, () => {
const config = option.getBatchKeys(path)
return config
}, interval)
return result
}
function getMySQLConf ({ key, option, time }) {
const interval = 1000 * (time || 60)
const result = createCache(`mysql-conf-${key}`, () => {
const config = option.getMysqlConf(key)
return config
}, interval)
return result
}
function qconfAllHost ({ key, option, path, time }) {
const interval = 1000 * (time || 60)
const result = createCache(`qconf-all-host-${key}`, () => {
const config = option.getQconfAllHost(path)
const outcome = config.map(item => item.split(':'))
const temporary = []
outcome.forEach(([host, port]) => {
temporary.push({
host,
port
})
})
return temporary
}, interval)
return result
}
function qconfConf ({ key, option, path, time }) {
const interval = 1000 * (time || 60)
const result = createCache(`qconf-conf-${key}`, () => {
const config = option.getQconfConf(path)
return config
}, interval)
return result
}
function qconfHost ({ key, option, path, time }) {
const interval = 1000 * (time || 60)
const result = createCache(`qconf-host-${key}`, () => {
const config = option.getQconfHost(path)
const temporary = { host: '', port: '' }
if (config) {
const [host, port] = config.split(':')
temporary.host = host
temporary.port = port
}
return temporary
}, interval)
return result
}
exports.batchKeys = batchKeys
exports.getMySQLConf = getMySQLConf
exports.qconfAllHost = qconfAllHost
exports.qconfConf = qconfConf
exports.qconfHost = qconfHost