2 * @brief Implementation of RemoteDatabase using a spawned server.
4 /* Copyright (C) 2007,2010,2011,2014,2019 Olly Betts
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_PROGCLIENT_H
22 #define XAPIAN_INCLUDED_PROGCLIENT_H
24 #include <sys/types.h>
26 #include "backends/remote/remote-database.h"
28 /** Implementation of RemoteDatabase using a spawned server.
30 * ProgClient spawns a child process to connect to the server - for example,
31 * an ssh command to run the server on a remote host. Communication with the
32 * child process is via a pipe.
34 class ProgClient
: public RemoteDatabase
{
35 /// Don't allow assignment.
36 void operator=(const ProgClient
&);
38 /// Don't allow copying.
39 ProgClient(const ProgClient
&);
42 /// Process id of the child process.
45 /// HANDLE of the child process.
49 /** Start the child process.
51 * @param progname The program used to create the connection.
52 * @param args Any arguments to the program.
53 * @param child Reference to store the child process pid/HANDLE in.
55 * @return file descriptor for reading from/writing to the child process.
57 * Note: this method is called early on during class construction before
58 * any member variables or even the base class have been initialised.
59 * To help avoid accidentally trying to use member variables, this method
60 * has been deliberately made "static".
62 static int run_program(const std::string
&progname
,
63 const std::string
&args
,
71 /** Generate context string for Xapian::Error exception objects.
73 * @param progname The program used to create the connection.
74 * @param args Any arguments to the program.
76 * Note: this method is used from constructors so has been made static to
77 * avoid problems with trying to use uninitialised member variables. In
78 * particular, it can't be made a virtual method of the base class.
80 static std::string
get_progcontext(const std::string
&progname
,
81 const std::string
&args
);
86 * @param progname The program used to create the connection.
87 * @param args Any arguments to the program.
88 * @param timeout Timeout for communication (in seconds).
89 * @param writable Is this a WritableDatabase?
90 * @param flags Xapian::DB_RETRY_LOCK or 0.
92 ProgClient(const std::string
&progname
,
93 const std::string
&arg
,
102 #endif // XAPIAN_INCLUDED_PROGCLIENT_H