Skip to content

Commit

Permalink
Allows to not send realtime notification on document controller (#1946)
Browse files Browse the repository at this point in the history
Add a silent option to the document controller actions.

When set, actions will not generate realtime notifications.

This feature is needed because if you write a document in the callback of a realtime notification, then you can enter an infinite loop.
  • Loading branch information
Aschen authored Jan 28, 2021
1 parent 7231538 commit 29f0a6d
Show file tree
Hide file tree
Showing 16 changed files with 291 additions and 100 deletions.
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/create-or-replace/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Creates a new document in the persistent data storage, or replaces its content i
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<documentId>[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/<documentId>[?refresh=wait_for][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -54,6 +54,7 @@ Body:
### Optional:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the created/replaced document is indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
5 changes: 3 additions & 2 deletions doc/2/api/controllers/document/create/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Returns an error if the document already exists.
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_create[?refresh=wait_for]
URL(2): http://kuzzle:7512/<index>/<collection>/<documentId>/_create[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/_create[?refresh=wait_for][&silent]
URL(2): http://kuzzle:7512/<index>/<collection>/<documentId>/_create[?refresh=wait_for][&silent]
Method: POST
Body:
```
Expand Down Expand Up @@ -57,6 +57,7 @@ Body:

- `documentId`: set the document unique ID to the provided value, instead of auto-generating a random ID
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the newly created document is indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/delete-by-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ To remove all documents from a collection, use [collection:truncate](/core/2/api
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_query[?refresh=wait_for][&source][&lang=<query language>]
URL: http://kuzzle:7512/<index>/<collection>/_query[?refresh=wait_for][&source][&lang=<query language>][&silent]
Method: DELETE
Body:
```
Expand Down Expand Up @@ -82,6 +82,7 @@ Body:
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the deleted documents are removed from the search indexes
- `source`: if set to `true` Kuzzle will return each deleted document body in the response.
- `lang`: specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="2.8.0"/>
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
4 changes: 3 additions & 1 deletion doc/2/api/controllers/document/delete-fields/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Deletes fields of an existing document.
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<documentId>/_fields[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/<documentId>/_fields[?refresh=wait_for][&silent]
Method: DELETE
Body:
```
Expand Down Expand Up @@ -59,6 +59,8 @@ Body:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the new document content is indexed
- `source`: if set to `true`, the response will contain the new updated document
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

## Body properties
Expand Down
4 changes: 3 additions & 1 deletion doc/2/api/controllers/document/delete/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Deletes a document.
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<documentId>[?refresh=wait_for][&source]
URL: http://kuzzle:7512/<index>/<collection>/<documentId>[?refresh=wait_for][&source][&silent]
Method: DELETE
```

Expand Down Expand Up @@ -45,6 +45,8 @@ Method: DELETE

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the deletion has been indexed
- `source`: if set to `true` Kuzzle will return the deleted document body in the response.
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

## Response
Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/m-create-or-replace/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The number of documents that can be created or replaced by a single request is l
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_mCreateOrReplace[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/_mCreateOrReplace[?refresh=wait_for][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -80,6 +80,7 @@ Body:
### Optional:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the created/replaced documents are indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/m-create/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The number of documents that can be created by a single request is limited by th
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_mCreate[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/_mCreate[?refresh=wait_for][&silent]
Method: POST
Body:
```
Expand Down Expand Up @@ -86,6 +86,7 @@ Body:
### Optional:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the newly created documents are indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/m-delete/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The number of documents that can be deleted by a single request is limited by th
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_mDelete[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/_mDelete[?refresh=wait_for][&silent]
Method: DELETE
Body:
```
Expand Down Expand Up @@ -54,6 +54,7 @@ Body:
### Optional:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the deletions are indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/m-replace/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The number of documents that can be replaced by a single request is limited by t
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_mReplace[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/_mReplace[?refresh=wait_for][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -76,6 +76,7 @@ Body:

- `collection`: collection name
- `index`: index name
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

### Optional:

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/m-update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ The number of documents that can be updated by a single request is limited by th
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_mUpdate[?refresh=wait_for][&retryOnConflict=<retries>]
URL: http://kuzzle:7512/<index>/<collection>/_mUpdate[?refresh=wait_for][&retryOnConflict=<retries>][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -81,6 +81,7 @@ Body:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the updates are indexed
- `retryOnConflict`: conflicts may occur if the same document gets updated multiple times within a short timespan in a database cluster. You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error.
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/replace/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Replaces the content of an existing document.
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<documentId>/_replace[?refresh=wait_for]
URL: http://kuzzle:7512/<index>/<collection>/<documentId>/_replace[?refresh=wait_for][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -55,6 +55,7 @@ Body:
### Optional:

- `refresh`: if set to `wait_for`, Kuzzle will not respond until the new document content is indexed
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/update-by-query/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ To update a greater number of documents, either change the server configuration,
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/_query[?refresh=wait_for][&source][&lang=<query language>]
URL: http://kuzzle:7512/<index>/<collection>/_query[?refresh=wait_for][&source][&lang=<query language>][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -81,6 +81,7 @@ Body:
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the update is indexed
- `source`: if set to `true` Kuzzle will return the updated documents body in the response.
- `lang`: specify the query language to use. By default, it's `elasticsearch` but `koncorde` can also be used. <SinceBadge version="2.8.0"/>
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

## Body properties

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/update/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Applies partial changes to a document. The document must exist in the storage la
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<_id>/_update[?refresh=wait_for][&retryOnConflict=<int>][&source]
URL: http://kuzzle:7512/<index>/<collection>/<_id>/_update[?refresh=wait_for][&retryOnConflict=<int>][&source][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -54,6 +54,7 @@ Body:
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the update is indexed
- `retryOnConflict`: conflicts may occur if the same document gets updated multiple times within a short timespan, in a database cluster. You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error.
- `source`: if set to `true` Kuzzle will return the entire updated document body in the response.
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
3 changes: 2 additions & 1 deletion doc/2/api/controllers/document/upsert/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Applies partial changes to a document. If the document doesn't already exist, a
### HTTP

```http
URL: http://kuzzle:7512/<index>/<collection>/<_id>/_upsert[?refresh=wait_for][&retryOnConflict=<int>][&source]
URL: http://kuzzle:7512/<index>/<collection>/<_id>/_upsert[?refresh=wait_for][&retryOnConflict=<int>][&source][&silent]
Method: PUT
Body:
```
Expand Down Expand Up @@ -68,6 +68,7 @@ Body:
- `refresh`: if set to `wait_for`, Kuzzle will not respond until the document is indexed
- `retryOnConflict`: conflicts may occur if the same document gets updated multiple times within a short timespan, in a database cluster. You can set the `retryOnConflict` optional argument (with a retry count), to tell Kuzzle to retry the failing updates the specified amount of times before rejecting the request with an error.
- `source`: if set to `true` Kuzzle will return the entire updated document body in the response.
- `silent`: if set, then Kuzzle will not generate notifications <SinceBadge version="change-me" />

---

Expand Down
Loading

0 comments on commit 29f0a6d

Please sign in to comment.