xapian-core  1.4.21
remoteserver.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2006,2007,2008,2009,2010,2014,2019 Olly Betts
5  * Copyright (C) 2007,2009,2010 Lemur Consulting Ltd
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #ifndef XAPIAN_INCLUDED_REMOTESERVER_H
23 #define XAPIAN_INCLUDED_REMOTESERVER_H
24 
25 #include "xapian/database.h"
26 #include "xapian/postingsource.h"
27 #include "xapian/registry.h"
28 #include "xapian/visibility.h"
29 #include "xapian/weight.h"
30 
31 #include "remoteconnection.h"
32 
33 #include <string>
34 
38  void operator=(const RemoteServer &);
39 
41  RemoteServer(const RemoteServer &);
42 
48 
51 
53  bool writable;
54 
61 
67  double idle_timeout;
68 
71 
73  message_type get_message(double timeout, std::string & result,
74  message_type required_type = MSG_MAX);
75 
77  void send_message(reply_type type, const std::string &message);
78 
80  void send_message(reply_type type, const std::string &message,
81  double end_time) {
82  unsigned char type_as_char = static_cast<unsigned char>(type);
83  RemoteConnection::send_message(type_as_char, message, end_time);
84  }
85 
86  // all terms
87  void msg_allterms(const std::string & message);
88 
89  // get document
90  void msg_document(const std::string & message);
91 
92  // term exists?
93  void msg_termexists(const std::string & message);
94 
95  // get collection freq
96  void msg_collfreq(const std::string & message);
97 
98  // get termfreq
99  void msg_termfreq(const std::string & message);
100 
101  // get termfreq and collection freq
102  void msg_freqs(const std::string & message);
103 
104  // get value statistics
105  void msg_valuestats(const std::string & message);
106 
107  // keep alive
108  void msg_keepalive(const std::string & message);
109 
110  // get doclength
111  void msg_doclength(const std::string & message);
112 
113  // set the query; return the mset
114  void msg_query(const std::string & message);
115 
116  // get termlist
117  void msg_termlist(const std::string & message);
118 
119  // get postlist
120  void msg_postlist(const std::string & message);
121 
122  // get positionlist
123  void msg_positionlist(const std::string &message);
124 
125  // get write access
126  void msg_writeaccess(const std::string & message);
127 
128  // reopen
129  void msg_reopen(const std::string & message);
130 
131  // get updated doccount and avlength
132  void msg_update(const std::string &message);
133 
134  // commit
135  void msg_commit(const std::string & message);
136 
137  // cancel (compat)
138  void msg_cancel_(const std::string &message);
139 
140  // add document
141  void msg_adddocument(const std::string & message);
142 
143  // delete document
144  void msg_deletedocument(const std::string & message);
145 
146  // delete document with unique term (compat)
147  void msg_deletedocumentterm_(const std::string & message);
148 
149  // replace document (compat)
150  void msg_replacedocument_(const std::string & message);
151 
152  // replace document with unique term
153  void msg_replacedocumentterm(const std::string & message);
154 
155  // get metadata
156  void msg_getmetadata(const std::string & message);
157 
158  // read metadata key list
159  void msg_openmetadatakeylist(const std::string & message);
160 
161  // set metadata (compat)
162  void msg_setmetadata_(const std::string & message);
163 
164  // add a spelling (compat)
165  void msg_addspelling_(const std::string & message);
166 
167  // remove a spelling
168  void msg_removespelling(const std::string & message);
169 
170  // get number of unique terms
171  void msg_uniqueterms(const std::string & message);
172 
173  // delete document with unique term
174  void msg_deletedocumentterm(const std::string & message);
175 
176  // replace document
177  void msg_replacedocument(const std::string & message);
178 
179  // cancel
180  void msg_cancel(const std::string &message);
181 
182  // set metadata
183  void msg_setmetadata(const std::string & message);
184 
185  // add a spelling
186  void msg_addspelling(const std::string & message);
187 
188  public:
201  RemoteServer(const std::vector<std::string> &dbpaths,
202  int fdin, int fdout,
203  double active_timeout_,
204  double idle_timeout_,
205  bool writable = false);
206 
208  ~RemoteServer();
209 
215  void run();
216 
218  void set_registry(const Xapian::Registry & reg_) { reg = reg_; }
219 };
220 
221 #endif // XAPIAN_INCLUDED_REMOTESERVER_H
A RemoteConnection object provides a bidirectional connection to another RemoteConnection object on a...
RemoteConnection class used by the remote backend.
int get_message(std::string &result, double end_time)
Read one message from fdin.
This class is used to access a database, or a group of databases.
Definition: database.h:68
unsigned timeout
A timeout value in milliseconds.
Definition: types.h:100
Xapian::WritableDatabase * wdb
The WritableDatabase we&#39;re using, or NULL if we&#39;re read-only.
Definition: remoteserver.h:50
double end_time(double timeout)
Return the end time for a timeout in timeout seconds.
Definition: realtime.h:95
External sources of posting information.
Xapian::Registry reg
The registry, which allows unserialisation of user subclasses.
Definition: remoteserver.h:70
reply_type
Reply types (server -> client).
double active_timeout
Timeout for actions during a conversation.
Definition: remoteserver.h:60
#define XAPIAN_VISIBILITY_DEFAULT
Definition: visibility.h:28
bool writable
Do we support writing?
Definition: remoteserver.h:53
This class provides read/write access to a database.
Definition: database.h:785
Define XAPIAN_VISIBILITY_* macros.
Registry for user subclasses.
Definition: registry.h:47
API for working with Xapian databases.
void send_message(reply_type type, const std::string &message, double end_time)
Send a message to the client, with specific end_time.
Definition: remoteserver.h:80
double idle_timeout
Timeout while waiting for a new action from the client.
Definition: remoteserver.h:67
Weighting scheme API.
void set_registry(const Xapian::Registry &reg_)
Set the registry used for (un)serialisation.
Definition: remoteserver.h:218
Xapian::Database * db
The database we&#39;re using.
Definition: remoteserver.h:47
message_type
Message types (client -> server).
void send_message(char type, const std::string &s, double end_time)
Send a message.
Remote backend server base class.
Definition: remoteserver.h:36
void operator=(const RemoteConnection &)
Don&#39;t allow assignment.
Class for looking up user subclasses during unserialisation.