##// END OF EJS Templates
repository: define new interface for running commands...
Gregory Szorc -
r37647:fa038208 default
parent child Browse files
Show More
@@ -196,6 +196,88 b' class ipeerlegacycommands(zi.Interface):'
196 def changegroupsubset(bases, heads, kind):
196 def changegroupsubset(bases, heads, kind):
197 pass
197 pass
198
198
199 class ipeercommandexecutor(zi.Interface):
200 """Represents a mechanism to execute remote commands.
201
202 This is the primary interface for requesting that wire protocol commands
203 be executed. Instances of this interface are active in a context manager
204 and have a well-defined lifetime. When the context manager exits, all
205 outstanding requests are waited on.
206 """
207
208 def callcommand(name, args):
209 """Request that a named command be executed.
210
211 Receives the command name and a dictionary of command arguments.
212
213 Returns a ``concurrent.futures.Future`` that will resolve to the
214 result of that command request. That exact value is left up to
215 the implementation and possibly varies by command.
216
217 Not all commands can coexist with other commands in an executor
218 instance: it depends on the underlying wire protocol transport being
219 used and the command itself.
220
221 Implementations MAY call ``sendcommands()`` automatically if the
222 requested command can not coexist with other commands in this executor.
223
224 Implementations MAY call ``sendcommands()`` automatically when the
225 future's ``result()`` is called. So, consumers using multiple
226 commands with an executor MUST ensure that ``result()`` is not called
227 until all command requests have been issued.
228 """
229
230 def sendcommands():
231 """Trigger submission of queued command requests.
232
233 Not all transports submit commands as soon as they are requested to
234 run. When called, this method forces queued command requests to be
235 issued. It will no-op if all commands have already been sent.
236
237 When called, no more new commands may be issued with this executor.
238 """
239
240 def close():
241 """Signal that this command request is finished.
242
243 When called, no more new commands may be issued. All outstanding
244 commands that have previously been issued are waited on before
245 returning. This not only includes waiting for the futures to resolve,
246 but also waiting for all response data to arrive. In other words,
247 calling this waits for all on-wire state for issued command requests
248 to finish.
249
250 When used as a context manager, this method is called when exiting the
251 context manager.
252
253 This method may call ``sendcommands()`` if there are buffered commands.
254 """
255
256 class ipeerrequests(zi.Interface):
257 """Interface for executing commands on a peer."""
258
259 def commandexecutor():
260 """A context manager that resolves to an ipeercommandexecutor.
261
262 The object this resolves to can be used to issue command requests
263 to the peer.
264
265 Callers should call its ``callcommand`` method to issue command
266 requests.
267
268 A new executor should be obtained for each distinct set of commands
269 (possibly just a single command) that the consumer wants to execute
270 as part of a single operation or round trip. This is because some
271 peers are half-duplex and/or don't support persistent connections.
272 e.g. in the case of HTTP peers, commands sent to an executor represent
273 a single HTTP request. While some peers may support multiple command
274 sends over the wire per executor, consumers need to code to the least
275 capable peer. So it should be assumed that command executors buffer
276 called commands until they are told to send them and that each
277 command executor could result in a new connection or wire-level request
278 being issued.
279 """
280
199 class ipeerbase(ipeerconnection, ipeercapabilities, ipeercommands):
281 class ipeerbase(ipeerconnection, ipeercapabilities, ipeercommands):
200 """Unified interface for peer repositories.
282 """Unified interface for peer repositories.
201
283
General Comments 0
You need to be logged in to leave comments. Login now