class Protocol {
public:
+ enum class proto_t {
+ none,
+ v1,
+ v2
+ };
+
Protocol(Protocol&&) = delete;
virtual ~Protocol();
const entity_addr_t& peer_addr) = 0;
protected:
- Protocol(int type,
+ Protocol(proto_t type,
Dispatcher& dispatcher,
SocketConnection& conn);
virtual seastar::future<> do_keepalive_ack() = 0;
public:
- const int proto_type;
+ const proto_t proto_type;
protected:
Dispatcher &dispatcher;
ProtocolV1::ProtocolV1(Dispatcher& dispatcher,
SocketConnection& conn,
SocketMessenger& messenger)
- : Protocol(1, dispatcher, conn), messenger{messenger} {}
+ : Protocol(proto_t::v1, dispatcher, conn), messenger{messenger} {}
ProtocolV1::~ProtocolV1() {}
return send_connect_reply(tag, std::move(authorizer_reply));
}
if (auto existing = messenger.lookup_conn(conn.peer_addr); existing) {
- if (existing->protocol->proto_type != 1) {
+ if (existing->protocol->proto_type != proto_t::v1) {
logger().warn("{} existing {} proto version is {} not 1, close existing",
- conn, *existing, existing->protocol->proto_type);
+ conn, *existing,
+ static_cast<int>(existing->protocol->proto_type));
existing->close();
} else {
return handle_connect_with_existing(existing, std::move(authorizer_reply));
ProtocolV2::ProtocolV2(Dispatcher& dispatcher,
SocketConnection& conn,
SocketMessenger& messenger)
- : Protocol(2, dispatcher, conn, messenger) {}
+ : Protocol(proto_t::v2, dispatcher, conn), messenger{messenger} {}
ProtocolV2::~ProtocolV2() {}
SocketConnectionRef existing = messenger.lookup_conn(conn.peer_addr);
if (existing) {
- if (existing->protocol->proto_type != 2) {
+ if (existing->protocol->proto_type != proto_t::v2) {
logger().warn("{} existing {} proto version is {}, close",
- conn, *existing, existing->protocol->proto_type);
+ conn, *existing,
+ static_cast<int>(existing->protocol->proto_type));
// should unregister the existing from msgr atomically
existing->close();
} else {
return send_reset(true);
}
- if (existing->protocol->proto_type != 2) {
+ if (existing->protocol->proto_type != proto_t::v2) {
logger().warn("{} server_reconnect: existing {} proto version is {},"
- "close existing and resetting client.", conn, *existing);
+ "close existing and resetting client.",
+ conn, *existing,
+ static_cast<int>(existing->protocol->proto_type));
existing->close();
return send_reset(true);
}