]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/crossdock/Server.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / jaegertracing / jaeger-client-cpp / crossdock / Server.h
1 /*
2 * Copyright (c) 2017 Uber Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef JAEGERTRACING_CROSSDOCK_SERVER_H
18 #define JAEGERTRACING_CROSSDOCK_SERVER_H
19
20 #include <memory>
21
22 #include <opentracing/tracer.h>
23
24 #include "jaegertracing/thrift-gen/tracetest_types.h"
25
26 namespace jaegertracing {
27 namespace logging {
28
29 class Logger;
30
31 } // namespace logging
32
33 namespace net {
34
35 class IPAddress;
36
37 namespace http {
38
39 class Request;
40
41 } // namespace http
42 } // namespace net
43
44 namespace crossdock {
45
46 class Server {
47 public:
48 Server(const net::IPAddress& clientIP,
49 const net::IPAddress& serverIP,
50 const std::string& agentHostPort,
51 const std::string& collectorEndpoint,
52 const std::string& samplingServerURL);
53
54 ~Server();
55
56 void serve();
57
58 private:
59 template <typename RequestType>
60 std::string handleJSON(
61 const net::http::Request& request,
62 std::function<thrift::TraceResponse(
63 const RequestType&, const opentracing::SpanContext&)> handler);
64
65 std::string handleRequest(const net::http::Request& request);
66
67 thrift::TraceResponse startTrace(const thrift::StartTraceRequest& request);
68
69 thrift::TraceResponse joinTrace(const thrift::JoinTraceRequest& request,
70 const opentracing::SpanContext& ctx);
71
72 std::string generateTraces(const net::http::Request& request);
73
74 class SocketListener;
75 class EndToEndHandler;
76
77 std::shared_ptr<logging::Logger> _logger;
78 std::shared_ptr<opentracing::Tracer> _tracer;
79 std::unique_ptr<SocketListener> _clientListener;
80 std::unique_ptr<SocketListener> _serverListener;
81 std::unique_ptr<EndToEndHandler> _handler;
82 };
83
84 } // namespace crossdock
85 } // namespace jaegertracing
86
87 #endif // JAEGERTRACING_CROSSDOCK_SERVER_H