1 | /** |
2 | * Copyright 2021 Alibaba, Inc. and its affiliates. All Rights Reserved. |
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 | * \author Haichao.chc |
17 | * \date Oct 2020 |
18 | * \brief Implementation with http protocol |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "grpc_client.h" |
24 | |
25 | namespace proxima { |
26 | namespace be { |
27 | |
28 | /* |
29 | * HttpProximaSearchClient communicate to BE server with http protocol |
30 | */ |
31 | class HttpProximaSearchClient : public GrpcProximaSearchClient { |
32 | public: |
33 | //! Constructor |
34 | HttpProximaSearchClient() = default; |
35 | |
36 | //! Destructor |
37 | ~HttpProximaSearchClient() override = default; |
38 | |
39 | //! Connect remote server |
40 | Status connect(const ChannelOptions &options) override; |
41 | |
42 | //! Close connection to remote server |
43 | Status close() override; |
44 | |
45 | /// Other functions inherit from GrpcProximaSearchClient |
46 | protected: |
47 | void rpc_create_collection(brpc::Controller *cntl, |
48 | const proto::CollectionConfig *request, |
49 | proto::Status *response) override; |
50 | |
51 | void rpc_drop_collection(brpc::Controller *cntl, |
52 | const proto::CollectionName *request, |
53 | proto::Status *response) override; |
54 | |
55 | void rpc_describe_collection( |
56 | brpc::Controller *cntl, const proto::CollectionName *request, |
57 | proto::DescribeCollectionResponse *response) override; |
58 | |
59 | void rpc_stats_collection(brpc::Controller *cntl, |
60 | const proto::CollectionName *request, |
61 | proto::StatsCollectionResponse *response) override; |
62 | |
63 | void rpc_list_collections(brpc::Controller *cntl, |
64 | const proto::ListCondition *request, |
65 | proto::ListCollectionsResponse *response) override; |
66 | |
67 | void rpc_write(brpc::Controller *cntl, const proto::WriteRequest *request, |
68 | proto::Status *response) override; |
69 | |
70 | void rpc_query(brpc::Controller *cntl, const proto::QueryRequest *request, |
71 | proto::QueryResponse *response) override; |
72 | |
73 | void rpc_get_document_by_key(brpc::Controller *cntl, |
74 | const proto::GetDocumentRequest *request, |
75 | proto::GetDocumentResponse *response) override; |
76 | |
77 | private: |
78 | Status check_server_version(); |
79 | |
80 | private: |
81 | brpc::Channel client_channel_{}; |
82 | std::string http_host_{}; |
83 | }; |
84 | |
85 | } // namespace be |
86 | } // end namespace proxima |
87 | |