-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add API actions to prune payloads collection #49
Conversation
### HTTP | ||
|
||
```http | ||
URL: http://kuzzle:7512/_/device-manager/devices/_clean_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL: http://kuzzle:7512/_/device-manager/devices/_clean_ | |
URL: http://kuzzle:7512/_/device-manager/devices/_clean |
|
||
# clean | ||
|
||
Cleans the payload collection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more info about the option available to clean the collection?
### Kourou | ||
|
||
```bash | ||
kourou device-manager/device:clean '{"days": <days>, "valid": "true|false", "deviceModel": "<deviceModel>"}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you transform the object in a multiline object for more readability?
Also it's not JSON so you don't need "
for properties name
## Arguments | ||
|
||
- `days`: Specify on which period of time you want keep payloads (`default: 7`). | ||
- `valid`: Specify which payloads are to be deleted (`default: true`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this should not be a boolean so people can choose between valid, invalid or both
- `valid`: Specify which payloads are to be deleted (`default: true`). | |
- `valid`: Specify if valid, invalid or both payload should be deleted (`default: true`). |
|
||
## Response | ||
|
||
Returns an array with the deleted payloads ids. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this is useless. Just the number of deleted payload is enough I think
@@ -27,3 +27,20 @@ Then(/I (successfully )?receive a "(.*?)" payload with:/, async function (expect | |||
this.props.error = error; | |||
} | |||
}); | |||
|
|||
Then(/I clean the payloads collection with args:/, async function (dataTable) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless step
lib/controllers/CRUDController.ts
Outdated
@@ -50,7 +50,7 @@ export class CRUDController extends NativeController { | |||
* | |||
* @param request | |||
*/ | |||
async delete (request: KuzzleRequest) { | |||
delete (request: KuzzleRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should stay async since handler function should always return a promise.
Here if anything goes wrong the method will throw an exception and not return a rejected promise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why only delete
? The others are not async
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm they all should be async
then
lib/controllers/DeviceController.ts
Outdated
const filter = [] | ||
filter.push({ | ||
range: { | ||
"_kuzzle_info.createdAt": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpicking: you should use single quote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The action name should be more explicite since it's in the device controller, something like cleanPayloads
Changelog label is missing |
description: Cleans the payload collection | ||
--- | ||
|
||
# cleanPayloads |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nitpicking) usually the associated term for that kind of operation is "prune": prunePayloads
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought prune
is used when everything is erased?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verb (used with object), pruned, prun·ing.
* to cut or lop off (twigs, branches, or roots).
* to cut or lop superfluous or undesired twigs, branches, or roots from; trim.
* to rid or clear of (anything superfluous or undesirable).
This seems adequate to me, since this action seems to allow the removal of superfluous payloads.
## Arguments | ||
|
||
- `days`: Specify on which period of time you want keep payloads (`default: 7`). | ||
- `valid`: Specify if valid, invalid or both payload should be deleted (`default: true`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can we keep both valid and invalid payloads with a boolean option? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm it's a mistake, we can't
Co-authored-by: Sébastien Cottinet <[email protected]>
## Arguments | ||
|
||
- `days`: The maximum age of a payload, in days (`default: 7`). | ||
- `valid`: Specify if valid or invalid payloads should be deleted (`default: true`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. This is unclear to me: if set to true
, does that mean that valid
payloads are removed, and invalid
ones are kept? If so, then that's a weird choice of a default value.
Otherwise, we could also understand that if set to true
, then valid
payloads are kept, and invalid ones are removed. But then, the documentation is wrong (or at least misleading): this option sets the kind of payloads to keep, not the ones to be removed.
In any case, that sentence suggests that this option allows to choose which kind of payload to keep (on or the other), but I don't think that this is how it's supposed to work.
Also, what is an "invalid payload"? This might be explained somewhere else in this documentation, but it seems weird that we keep those if they are invalid 🤔
I have a proposal to make things clearer, but we might need to modify it depending on what's the definition of an "invalid payload":
- `valid`: Specify if valid or invalid payloads should be deleted (`default: true`). | |
- `consolidate`: if set to true, ensure that only still-valid payloads are kept (`default: true`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid payload are the most interesting one because they are payload that couldn't be decoded properly by the associated decoder.
Developers can replay those payloads and try to understand how to decode them.
Maybe we can have an option keepInvalid
so by default they are all deleted but we can choose to keep to invalid one for further analysis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @Aschen on this one
Wdyt @scottinet ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm ok with that.
Co-authored-by: Michele Leo <[email protected]>
Co-authored-by: Michele Leo <[email protected]>
Add an API action to clean the
payloads
collection bydays
and/orvalid
payloads and/ordeviceModel
Closes #27