1
#pragma once
2

            
3
#include "envoy/server/factory_context.h"
4
#include "envoy/server/instance.h"
5

            
6
#include "source/common/config/metadata.h"
7

            
8
namespace Envoy {
9
namespace Server {
10

            
11
class FactoryContextImplBase : virtual public Configuration::FactoryContext {
12
public:
13
  FactoryContextImplBase(Server::Instance& server,
14
                         ProtobufMessage::ValidationVisitor& validation_visitor,
15
                         Stats::ScopeSharedPtr scope, Stats::ScopeSharedPtr listener_scope,
16
                         const Network::ListenerInfoConstSharedPtr& listener_info);
17

            
18
  // Configuration::FactoryContext
19
  Configuration::ServerFactoryContext& serverFactoryContext() override;
20
  Stats::Scope& scope() override;
21
  ProtobufMessage::ValidationVisitor& messageValidationVisitor() override;
22
  const Network::ListenerInfo& listenerInfo() const override;
23

            
24
  Stats::Scope& listenerScope() override;
25

            
26
protected:
27
  Server::Instance& server_;
28
  ProtobufMessage::ValidationVisitor& validation_visitor_;
29
  // Listener scope without the listener prefix.
30
  Stats::ScopeSharedPtr scope_;
31
  // Listener scope with the listener prefix.
32
  Stats::ScopeSharedPtr listener_scope_;
33
  const Network::ListenerInfoConstSharedPtr listener_info_;
34
};
35

            
36
/**
37
 * Implementation of FactoryContext wrapping a Server::Instance and some listener components.
38
 */
39
class FactoryContextImpl : public FactoryContextImplBase {
40
public:
41
  FactoryContextImpl(Server::Instance& server, Network::DrainDecision& drain_decision,
42
                     Stats::ScopeSharedPtr scope, Stats::ScopeSharedPtr listener_scope,
43
                     const Network::ListenerInfoConstSharedPtr& listener_info);
44

            
45
  // Configuration::FactoryContext
46
  Init::Manager& initManager() override;
47
  Network::DrainDecision& drainDecision() override;
48

            
49
private:
50
  Network::DrainDecision& drain_decision_;
51
};
52

            
53
} // namespace Server
54
} // namespace Envoy