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 Dianzhang.Chen
17 * \date Dec 2020
18 * \brief Interface of MysqlRepository
19 */
20
21#pragma once
22
23#include <string>
24#include <ailego/io/pid_file.h>
25#include <ailego/pattern/singleton.h>
26#include "repository/collection_manager.h"
27
28namespace proxima {
29namespace be {
30namespace repository {
31
32class MysqlRepository : public ailego::Singleton<MysqlRepository> {
33 public:
34 //! Initialize
35 int init(bool daemonized, const std::string &pid_file);
36
37 //! Cleanup memory
38 int cleanup();
39
40 //! Start server
41 int start();
42
43 //! Stop server
44 int stop();
45
46 private:
47 //! Initilize logger
48 int init_logger();
49
50 //! Start as daemon
51 void daemonize();
52
53 private:
54 bool daemonized_{false};
55 ailego::PidFile pid_file_{};
56
57 CollectionManagerPtr collection_manager_{};
58
59 bool is_running_{false};
60 std::mutex mutex_{};
61};
62
63} // end namespace repository
64} // namespace be
65} // end namespace proxima
66