| 236 | } |
| 237 | |
| 238 | void connect(const id::UUID& _connectionId) |
| 239 | { |
| 240 | // It is possible that a new endpoint was detected while we were |
| 241 | // waiting to establish a connection with the old master. |
| 242 | if (connectionId != _connectionId) { |
| 243 | VLOG(1) << "Ignoring connection attempt from stale connection"; |
| 244 | return; |
| 245 | } |
| 246 | |
| 247 | CHECK_SOME(endpoint); |
| 248 | CHECK_EQ(State::DISCONNECTED, state); |
| 249 | |
| 250 | state = State::CONNECTING; |
| 251 | |
| 252 | // We create two persistent connections here, one for subscribe |
| 253 | // call/streaming response and another for non-subscribe |
| 254 | // calls/responses. |
| 255 | collect( |
| 256 | process::http::connect(endpoint.get()), |
| 257 | process::http::connect(endpoint.get())) |
| 258 | .onAny(defer(self(), &Self::connected, connectionId.get(), lambda::_1)); |
| 259 | } |
| 260 | |
| 261 | void connected( |
| 262 | const id::UUID& _connectionId, |