1
#include "source/extensions/upstreams/http/generic/config.h"
2

            
3
#include "source/extensions/upstreams/http/http/upstream_request.h"
4
#include "source/extensions/upstreams/http/tcp/upstream_request.h"
5
#include "source/extensions/upstreams/http/udp/upstream_request.h"
6

            
7
namespace Envoy {
8
namespace Extensions {
9
namespace Upstreams {
10
namespace Http {
11
namespace Generic {
12

            
13
using UpstreamProtocol = Envoy::Router::GenericConnPoolFactory::UpstreamProtocol;
14

            
15
Router::GenericConnPoolPtr GenericGenericConnPoolFactory::createGenericConnPool(
16
    Upstream::HostConstSharedPtr host, Upstream::ThreadLocalCluster& thread_local_cluster,
17
    UpstreamProtocol upstream_protocol, Upstream::ResourcePriority priority,
18
    absl::optional<Envoy::Http::Protocol> downstream_protocol, Upstream::LoadBalancerContext* ctx,
19
47469
    const Protobuf::Message&) const {
20
47469
  Router::GenericConnPoolPtr conn_pool;
21
47469
  switch (upstream_protocol) {
22
47069
  case UpstreamProtocol::HTTP:
23
47069
    conn_pool = std::make_unique<Upstreams::Http::Http::HttpConnPool>(
24
47069
        host, thread_local_cluster, priority, downstream_protocol, ctx);
25
47069
    return (conn_pool->valid() ? std::move(conn_pool) : nullptr);
26
366
  case UpstreamProtocol::TCP:
27
366
    conn_pool = std::make_unique<Upstreams::Http::Tcp::TcpConnPool>(host, thread_local_cluster,
28
366
                                                                    priority, ctx);
29
366
    return (conn_pool->valid() ? std::move(conn_pool) : nullptr);
30
33
  case UpstreamProtocol::UDP:
31
33
    conn_pool = std::make_unique<Upstreams::Http::Udp::UdpConnPool>(host);
32
33
    return (conn_pool->valid() ? std::move(conn_pool) : nullptr);
33
47469
  }
34

            
35
1
  return nullptr;
36
47469
}
37

            
38
REGISTER_FACTORY(GenericGenericConnPoolFactory, Router::GenericConnPoolFactory);
39

            
40
} // namespace Generic
41
} // namespace Http
42
} // namespace Upstreams
43
} // namespace Extensions
44
} // namespace Envoy