77 {
88 "redisAdminUser" : "admin",
99 "redisAdminPass" : "adminpassword",
10- "caCert" : "certs/ca.crt",
11- "tlsKey" : "certs/tls.key",
1210 "debug" : true,
1311 "port" : 6379,
1412 "servers" : ["redis-0.redis:6379", "redis-1.redis:6379", "redis-2.redis:6379"],
13+ "caCert" : "certs/ca.crt",
14+ "tlsKey" : "certs/tls.key",
1515 "connectTimeout" : "1s",
1616 "readTimeout" : "1s",
1717 "healthcheck" : {
@@ -36,21 +36,14 @@ data:
3636 _check: resp => (
3737 (data, role) => (
3838 unhealthy_nodes.remove(_target),
39+ config.debug && console.log(`Response data: ${resp.toString()}`),
3940 data = resp.shift(40).toString().split('\r\n'),
4041 role = data[3].split(':')[1],
4142 config.debug && console.log(`Role is ${role} for ${_target}`),
4243 role === 'master' && unhealthy_master.remove(_target)
4344 ))()
4445 })
45- .listen(config.port)
46- .acceptTLS({
47- certificate: {
48- cert: new crypto.Certificate(pipy.load(config.caCert)),
49- key: new crypto.PrivateKey(pipy.load(config.tlsKey))
50- }
51- }).to('preconnection')
52-
53- .pipeline('preconnection')
46+ .listen(config.port)
5447 .handleData(
5548 (data, query, command, master_only) => (
5649 query = new Data(data).shift(20).toString(),
7366 config.debug && console.log(`Sending request to node ${_target}`)
7467 )
7568 )
76- .connectTLS({
77- certificate: {
78- cert: new crypto.Certificate(pipy.load(config.caCert)),
79- key: new crypto.PrivateKey(pipy.load(config.tlsKey))
80- }
81- }).to('sendconnection')
82-
83- .pipeline('sendconnection')
8469 .connect(() => _target,
8570 {
8671 connectTimeout: config.connectTimeout,
10388 unhealthy_nodes.set(t, true),
10489 unhealthy_master.set(t, true)
10590 )),
106- _counter = { n: 0 },
107- console.log(`Debug 0`)
91+ _counter = { n: 0 }
10892 )
10993 )
11094 .fork('per-node',
@@ -115,23 +99,22 @@ data:
11599 .wait(
116100 () => _counter.n === 0
117101 )
118-
102+
119103 .pipeline('per-node')
120104 .replaceMessage(
121105 () => (
122106 _counter.n++,
123- new Message(`AUTH ${config.redisAdminUser} ${config.redisAdminPass}\r\ninfo replication\r\n`),
124- console.log(`Debug 1`)
107+ new Message(`AUTH ${config.redisAdminUser} ${config.redisAdminPass}\r\ninfo replication\r\n`)
125108 )
126109 )
127110 .connectTLS({
128111 certificate: {
129112 cert: new crypto.Certificate(pipy.load(config.caCert)),
130113 key: new crypto.PrivateKey(pipy.load(config.tlsKey))
131114 }
132- }).to('healthconnection ')
133-
134- .pipeline('healthconnection ')
115+ }).to('sendconnection ')
116+
117+ .pipeline('sendconnection ')
135118 .connect(
136119 () => _target,
137120 {
@@ -140,8 +123,7 @@ data:
140123 }
141124 )
142125 .handleData(
143- data => _check(data),
144- console.log(`Debug 2`)
126+ data => _check(data)
145127 )
146128 .handleStreamEnd(
147129 () => _counter.n--
0 commit comments