blob: ab1ade79f8342bf0012214bf71b31389f1af019a [file] [log] [blame]
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Davide Pesavento3c843162019-07-07 15:06:44 -04002/*
Davide Pesaventod8521aa2023-09-17 14:21:27 -04003 * Copyright (c) 2014-2023, Regents of the University of California.
Alexander Afanasyeve1e6f2a2014-04-25 11:28:12 -07004 *
5 * This file is part of NDN repo-ng (Next generation of NDN repository).
6 * See AUTHORS.md for complete list of repo-ng authors and contributors.
7 *
8 * repo-ng is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070018 */
19
Alexander Afanasyev39d98072014-05-04 12:46:29 -070020#ifndef REPO_HANDLES_TCP_BULK_INSERT_HANDLE_HPP
21#define REPO_HANDLES_TCP_BULK_INSERT_HANDLE_HPP
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070022
Alexander Afanasyev39d98072014-05-04 12:46:29 -070023#include "common.hpp"
Weiqi Shif0330d52014-07-09 10:54:27 -070024#include "storage/repo-storage.hpp"
Alexander Afanasyev39d98072014-05-04 12:46:29 -070025
Davide Pesavento3c843162019-07-07 15:06:44 -040026#include <boost/asio/ip/tcp.hpp>
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070027
28namespace repo {
29
30class TcpBulkInsertHandle : noncopyable
31{
32public:
33 class Error : public std::runtime_error
34 {
35 public:
Davide Pesavento11904062022-04-14 22:33:28 -040036 using std::runtime_error::runtime_error;
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070037 };
38
39public:
Davide Pesaventod8521aa2023-09-17 14:21:27 -040040 TcpBulkInsertHandle(boost::asio::io_context& io, RepoStorage& storageHandle);
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070041
42 void
43 listen(const std::string& host, const std::string& port);
44
45 void
46 stop();
47
Weiqi Shif0330d52014-07-09 10:54:27 -070048 RepoStorage&
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070049 getStorageHandle()
50 {
51 return m_storageHandle;
52 }
53
54private:
55 void
Davide Pesavento3c843162019-07-07 15:06:44 -040056 asyncAccept();
57
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070058private:
59 boost::asio::ip::tcp::acceptor m_acceptor;
60 boost::asio::ip::tcp::endpoint m_localEndpoint;
Weiqi Shif0330d52014-07-09 10:54:27 -070061 RepoStorage& m_storageHandle;
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -070062};
63
64} // namespace repo
65
Alexander Afanasyev39d98072014-05-04 12:46:29 -070066#endif // REPO_HANDLES_TCP_BULK_INSERT_HANDLE_HPP