]>
git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/net/Dispatcher.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2017 Red Hat, Inc
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
21 namespace crimson::net
{
25 virtual ~Dispatcher() {}
27 // Dispatchers are put into a chain as described by chain-of-responsibility
28 // pattern. If any of the dispatchers claims this message, it returns a valid
29 // future to prevent other dispatchers from processing it, and this is also
30 // used to throttle the connection if it's too busy.
31 virtual std::optional
<seastar::future
<>> ms_dispatch(ConnectionRef
, MessageRef
) = 0;
33 // The connection is moving to the new_shard under accept/connect.
34 // User should not operate conn in this shard thereafter.
35 virtual void ms_handle_shard_change(
37 seastar::shard_id new_shard
,
38 bool is_accept_or_connect
) {}
40 // The connection is accepted or recoverred(lossless), all the followup
41 // events and messages will be dispatched to this shard.
43 // is_replace=true means the accepted connection has replaced
44 // another connecting connection with the same peer_addr, which currently only
45 // happens under lossy policy when both sides wish to connect to each other.
46 virtual void ms_handle_accept(ConnectionRef conn
, seastar::shard_id prv_shard
, bool is_replace
) {}
48 // The connection is (re)connected, all the followup events and messages will
49 // be dispatched to this shard.
50 virtual void ms_handle_connect(ConnectionRef conn
, seastar::shard_id prv_shard
) {}
52 // a reset event is dispatched when the connection is closed unexpectedly.
54 // is_replace=true means the reset connection is going to be replaced by
55 // another accepting connection with the same peer_addr, which currently only
56 // happens under lossy policy when both sides wish to connect to each other.
57 virtual void ms_handle_reset(ConnectionRef conn
, bool is_replace
) {}
59 virtual void ms_handle_remote_reset(ConnectionRef conn
) {}
62 } // namespace crimson::net