From ab2a8676c58f5b450942939985484ecad0cd5603 Mon Sep 17 00:00:00 2001 From: Andrea Leopardi Date: Thu, 17 Aug 2023 12:41:47 +0200 Subject: [PATCH] Handle :disconnected messages from connections --- lib/xandra/cluster/pool.ex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/xandra/cluster/pool.ex b/lib/xandra/cluster/pool.ex index 1db42fd2..aa94ccca 100644 --- a/lib/xandra/cluster/pool.ex +++ b/lib/xandra/cluster/pool.ex @@ -357,6 +357,20 @@ defmodule Xandra.Cluster.Pool do {:next_state, :has_connected_once, data, actions} end + # Sent by the connection itself. + def handle_event( + :info, + {:xandra, :disconnected, peername, _pid}, + _state, + %__MODULE__{} = data + ) + when is_peername(peername) do + # Not connected anymore, but we're not really sure if the whole host is down. + data = put_in(data.peers[peername].status, :up) + data = stop_pool(data, data.peers[peername].host) + {:keep_state, data} + end + # Sent by the connection itself. def handle_event( :info,