TensorFlow Serving C++ API Documentation
httpclient.h
1 /* Copyright 2020 Google Inc. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7  http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
17 #define THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
18 
19 #include "absl/memory/memory.h"
20 #include "tensorflow_serving/util/net_http/client/test_client/internal/evhttp_connection.h"
21 #include "tensorflow_serving/util/net_http/client/test_client/public/httpclient_interface.h"
22 
23 // Factory to manage internal dependency
24 // NOTE: This API is not yet finalized, and should in its current state be
25 // considered experimental
26 
27 namespace tensorflow {
28 namespace serving {
29 namespace net_http {
30 
31 // Creates a connection to a server implemented based on the libevents library.
32 // Returns nullptr if there is any error.
33 inline std::unique_ptr<TestHTTPClientInterface> CreateEvHTTPConnection(
34  absl::string_view host, int port) {
35  auto connection = absl::make_unique<TestEvHTTPConnection>();
36  connection = connection->Connect(host, port);
37  if (!connection) {
38  return nullptr;
39  }
40 
41  return std::move(connection);
42 }
43 
44 } // namespace net_http
45 } // namespace serving
46 } // namespace tensorflow
47 
48 #endif // THIRD_PARTY_TENSORFLOW_SERVING_UTIL_NET_HTTP_CLIENT_TEST_CLIENT_PUBLIC_HTTPCLIENT_H_
49