]> git.proxmox.com Git - ceph.git/blob - ceph/src/crimson/net/Dispatcher.h
cc6fd4574c7518da11c8471352ba1b0f35d0671d
[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 virtual void ms_handle_accept(ConnectionRef conn) {}
34
35 virtual void ms_handle_connect(ConnectionRef conn) {}
36
37 // a reset event is dispatched when the connection is closed unexpectedly.
38 // is_replace=true means the reset connection is going to be replaced by
39 // another accepting connection with the same peer_addr, which currently only
40 // happens under lossy policy when both sides wish to connect to each other.
41 virtual void ms_handle_reset(ConnectionRef conn, bool is_replace) {}
42
43 virtual void ms_handle_remote_reset(ConnectionRef conn) {}
44 };
45
46 } // namespace crimson::net