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 guonix |
17 | * \date Dec 2020 |
18 | * \brief |
19 | */ |
20 | |
21 | #pragma once |
22 | |
23 | #include "query_service.h" |
24 | |
25 | namespace proxima { |
26 | namespace be { |
27 | namespace query { |
28 | |
29 | //! Predefine class |
30 | class QueryAgent; |
31 | //! Alias Pointer for QueryAgent |
32 | using QueryAgentPtr = std::shared_ptr<QueryAgent>; |
33 | |
34 | /*! |
35 | * QueryAgent interface |
36 | */ |
37 | class QueryAgent { |
38 | public: |
39 | //! Create one QueryAgent instance |
40 | //! @param: concurrency: the buckets of execution queue, equal 0, means |
41 | // using hardware concurrency |
42 | static QueryAgentPtr Create(index::IndexServicePtr index_service, |
43 | meta::MetaServicePtr meta_service, |
44 | uint32_t concurrency); |
45 | |
46 | public: |
47 | //! Destructor |
48 | virtual ~QueryAgent() = default; |
49 | |
50 | //! Get Query Service Instance |
51 | virtual QueryServicePtr get_service() const = 0; |
52 | |
53 | public: |
54 | //! Query Service |
55 | virtual int search(const proto::QueryRequest *query, |
56 | proto::QueryResponse *response) = 0; |
57 | |
58 | //! Query document by key |
59 | virtual int search_by_key(const proto::GetDocumentRequest *query, |
60 | proto::GetDocumentResponse *response) = 0; |
61 | |
62 | public: |
63 | //! Init Query Agent |
64 | virtual int init() = 0; |
65 | |
66 | //! Cleanup Query Agent |
67 | virtual int cleanup() = 0; |
68 | |
69 | //! Start background service |
70 | virtual int start() = 0; |
71 | |
72 | //! Stop background service |
73 | virtual int stop() = 0; |
74 | |
75 | //! Return running status |
76 | virtual int is_running() = 0; |
77 | }; |
78 | |
79 | |
80 | } // namespace query |
81 | } // namespace be |
82 | } // namespace proxima |
83 | |