Debian Codegraph @

doc/source/reference/commands/request_cancel.rst

raw
1 .. -*- rst -*-
2
3 ``request_cancel``
4 ==================
5
6 Summary
7 -------
8
9 .. versionadded:: 4.0.9
10
11 ``request_cancel`` command cancels a running request.
12
13 There are some limitations:
14
15 * Request ID must be managed by user. (You need to assign unique key
16 for each request.)
17 * Cancel request may be ignored. (You can send ``request_cancel``
18 command multiple times for the same request ID.)
19 * Only multithreading type Groonga server is supported. (You can use
20 with :doc:`/reference/executables/groonga` based server but can't
21 use with :doc:`/reference/executables/groonga-httpd`.)
22
23 See :doc:`/reference/command/request_id` about request ID.
24
25 If the request is canceled, a :doc:`/reference/command/return_code` of the canceled request as below.
26
27 * ``-5`` (``GRN_INTERRUPTED_FUNCTION_CALL``) (Groonga version 6.0.1 before)
28 * ``-77`` (``GRN_CANCEL``) (Groonga version 6.0.1 or later)
29
30 Syntax
31 ------
32
33 This command takes only one required parameter::
34
35 request_cancel id
36
37 Usage
38 -----
39
40 Here is an example of ``request_cancel`` command::
41
42 $ curl 'http://localhost:10041/d/select?table=LargeTable&filter=true&request_id=unique-id-1' &
43 # The above "select" takes a long time...
44 # Point: "request_id=unique-id-1"
45 $ curl 'http://localhost:10041/d/request_cancel?id=unique-id-1'
46 [[...], {"id": "unique-id-1", "canceled": true}]
47 # Point: "id=unique-id-1"
48
49 Assume that the first ``select`` command takes a long
50 time. ``unique-id-1`` request ID is assigned to the ``select`` command
51 by ``request_id=unique-id-1`` parameter.
52
53 The second ``request_cancel`` command passes ``id=unique-id-1``
54 parameter. ``unique-id-1`` is the same request ID passed in ``select``
55 command.
56
57 The ``select`` command may not be canceled immediately. And the cancel
58 request may be ignored.
59
60 You can send cancel request for the same request ID multiple times. If
61 the target request is canceled or finished, ``"canceled"`` value is
62 changed to ``false`` from ``true`` in return value::
63
64 $ curl 'http://localhost:10041/d/request_cancel?id=unique-id-1'
65 [[...], {"id": "unique-id-1", "canceled": true}]
66 # "select" is still running... ("canceled" is "true")
67 $ curl 'http://localhost:10041/d/request_cancel?id=unique-id-1'
68 [[...], {"id": "unique-id-1", "canceled": true}]
69 # "select" is still running... ("canceled" is "true")
70 $ curl 'http://localhost:10041/d/request_cancel?id=unique-id-1'
71 [[...], {"id": "unique-id-1", "canceled": false}]
72 # "select" is canceled or finished. ("canceled" is "false")
73
74 If the ``select`` command is canceled, response of the ``select``
75 command has ``-5`` (``GRN_INTERRUPTED_FUNCTION_CALL``) as
76 :doc:`/reference/command/return_code`::
77
78 $ curl 'http://localhost:10041/d/select?table=LargeTable&filter=true&request_id=unique-id-1' &
79 [[-5, ...], ...]
80
81 Parameters
82 ----------
83
84 This section describes parameters of ``request_cancel``.
85
86 Required parameters
87 ^^^^^^^^^^^^^^^^^^^
88
89 There is required parameter, ``id``.
90
91 ``id``
92 """"""
93
94 Specifies the ID for the target request.
95
96 Return value
97 ------------
98
99 ``request_cancel`` command returns the result of the cancel request::
100
101 [
102 HEADER,
103 {
104 "id": ID,
105 "canceled": CANCEL_REQUEST_IS_ACCEPTED_OR_NOT
106 }
107 ]
108
109 ``HEADER``
110
111 See :doc:`/reference/command/output_format` about ``HEADER``.
112
113 ``ID``
114
115 The ID of the target request.
116
117 ``CANCEL_REQUEST_IS_ACCEPTED_OR_NOT``
118
119 If the cancel request is accepted, this is ``true``, otherwise this
120 is ``false``.
121
122 Note that "cancel request is accepted" doesn't means that "the
123 target request is canceled". It just means "cancel request is
124 notified to the target request but the cancel request may be ignored
125 by the target request".
126
127 If request assigned with the request ID doesn't exist, this is
128 ``false``.
129
130 See also
131 --------
132
133 * :doc:`/reference/command/request_id`