virtual ~Connection() {}
+ /**
+ * get_shard_id
+ *
+ * The shard id where the Connection is dispatching events and handling I/O.
+ *
+ * May be changed with the accept/connect events.
+ */
+ virtual const seastar::shard_id get_shard_id() const = 0;
+
virtual const entity_name_t &get_peer_name() const = 0;
entity_type_t get_peer_type() const { return get_peer_name().type(); }
* ConnectionHandler
*
* The interface class to implement Connection, called by SocketConnection.
+ *
+ * The operations must be done in get_shard_id().
*/
class ConnectionHandler {
public:
};
class SocketConnection : public Connection {
- // Connection interfaces, public to users
+ /*
+ * Connection interfaces, public to users
+ * Working in ConnectionHandler::get_shard_id()
+ */
public:
SocketConnection(SocketMessenger& messenger,
ChainedDispatchers& dispatchers);
~SocketConnection() override;
+ const seastar::shard_id get_shard_id() const override {
+ return io_handler->get_shard_id();
+ }
+
const entity_name_t &get_peer_name() const override {
return peer_name;
}