summaryrefslogtreecommitdiffstats
path: root/src/crimson/net/Dispatcher.h
blob: cc6fd4574c7518da11c8471352ba1b0f35d0671d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2017 Red Hat, Inc
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#pragma once

#include "Fwd.h"

class AuthAuthorizer;

namespace crimson::net {

class Dispatcher {
 public:
  virtual ~Dispatcher() {}

  // Dispatchers are put into a chain as described by chain-of-responsibility
  // pattern. If any of the dispatchers claims this message, it returns a valid
  // future to prevent other dispatchers from processing it, and this is also
  // used to throttle the connection if it's too busy.
  virtual std::optional<seastar::future<>> ms_dispatch(ConnectionRef, MessageRef) = 0;

  virtual void ms_handle_accept(ConnectionRef conn) {}

  virtual void ms_handle_connect(ConnectionRef conn) {}

  // a reset event is dispatched when the connection is closed unexpectedly.
  // is_replace=true means the reset connection is going to be replaced by
  // another accepting connection with the same peer_addr, which currently only
  // happens under lossy policy when both sides wish to connect to each other.
  virtual void ms_handle_reset(ConnectionRef conn, bool is_replace) {}

  virtual void ms_handle_remote_reset(ConnectionRef conn) {}
};

} // namespace crimson::net