xapian-core  2.0.0
dbfactory_remote.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2006,2007,2008,2010,2011,2014,2024 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #include <config.h>
22 
23 #include <xapian/dbfactory.h>
24 
25 #include "debuglog.h"
26 #include "net/progclient.h"
27 #include "net/remotetcpclient.h"
28 
29 #include <string_view>
30 
31 using namespace std;
32 
33 namespace Xapian {
34 
35 Database
36 Remote::open(string_view host, unsigned int port, unsigned timeout_,
37  unsigned connect_timeout)
38 {
39  LOGCALL_STATIC(API, Database, "Remote::open", host | port | timeout_ | connect_timeout);
40  RETURN(Database(new RemoteTcpClient(host, port, timeout_ * 1e-3,
41  connect_timeout * 1e-3, false, 0)));
42 }
43 
45 Remote::open_writable(string_view host, unsigned int port,
46  unsigned timeout_, unsigned connect_timeout,
47  int flags)
48 {
49  LOGCALL_STATIC(API, WritableDatabase, "Remote::open_writable", host | port | timeout_ | connect_timeout | flags);
50  RETURN(WritableDatabase(new RemoteTcpClient(host, port, timeout_ * 1e-3,
51  connect_timeout * 1e-3, true,
52  flags)));
53 }
54 
56 Remote::open(string_view program, string_view args,
57  unsigned timeout_)
58 {
59  LOGCALL_STATIC(API, Database, "Remote::open", program | args | timeout_);
60  RETURN(Database(new ProgClient(program, args, timeout_ * 1e-3, false, 0)));
61 }
62 
64 Remote::open_writable(string_view program, string_view args,
65  unsigned timeout_, int flags)
66 {
67  LOGCALL_STATIC(API, WritableDatabase, "Remote::open_writable", program | args | timeout_ | flags);
68  RETURN(WritableDatabase(new ProgClient(program, args,
69  timeout_ * 1e-3, true, flags)));
70 }
71 
72 }
Implementation of RemoteDatabase using a spawned server.
Definition: progclient.h:37
TCP/IP socket based RemoteDatabase implementation.
An indexed database of documents.
Definition: database.h:75
This class provides read/write access to a database.
Definition: database.h:964
Factory functions for constructing Database and WritableDatabase objects.
Debug logging macros.
#define RETURN(...)
Definition: debuglog.h:484
#define LOGCALL_STATIC(CATEGORY, TYPE, FUNC, PARAMS)
Definition: debuglog.h:482
WritableDatabase open_writable(std::string_view host, unsigned int port, unsigned timeout=0, unsigned connect_timeout=10000, int flags=0)
Construct a WritableDatabase object for update access to a remote database accessed via a TCP connect...
Database open(std::string_view host, unsigned int port, unsigned timeout=10000, unsigned connect_timeout=10000)
Construct a Database object for read-only access to a remote database accessed via a TCP connection.
The Xapian namespace contains public interfaces for the Xapian library.
Definition: compactor.cc:82
Implementation of RemoteDatabase using a spawned server.
TCP/IP socket based RemoteDatabase implementation.