]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/net/Dispatcher.h
update ceph source to reef 18.2.1
[ceph.git] / 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
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2017 Red Hat, Inc
7 *
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.
12 *
13 */
14
15 #pragma once
16
17 #include "Fwd.h"
18
19 class AuthAuthorizer;
20
21 namespace crimson::net {
22
23 class Dispatcher {
24 public:
25 virtual ~Dispatcher() {}
26
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;
32
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(
36 ConnectionRef conn,
37 seastar::shard_id new_shard,
38 bool is_accept_or_connect) {}
39
40 // The connection is accepted or recoverred(lossless), all the followup
41 // events and messages will be dispatched to this shard.
42 //
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) {}
47
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) {}
51
52 // a reset event is dispatched when the connection is closed unexpectedly.
53 //
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) {}
58
59 virtual void ms_handle_remote_reset(ConnectionRef conn) {}
60 };
61
62 } // namespace crimson::net