-
Notifications
You must be signed in to change notification settings - Fork 123
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
Feat(funnel): allow pluginRequest to trigger events #2542
Conversation
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.
We should get a way to had this flag through calling internal sdk API such as this.sdk.document.create( "my_index", "my_collection", {...} , { 'allowTriggerEvent' : true}
It is already the case, here is the code in the Iot platform with the custom controller that I used to test the feature customCreateDocument: {
handler: async (request: KuzzleRequest) => {
const res = await this.sdk.document.create(
request.getIndex(),
'measures',
{
values: { zone: 'CREATED VIA CONTROLLER' },
},
undefined,
{ allowTriggerEvents: request.input.allowTriggerEvents },
);
return res;
},
},
```
the methods on sdk.document takes an option object (here the 5th argument) in which we can set the flag |
|
Quality Gate passedIssues Measures |
🎉 This PR is included in version 2.31.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 2.31.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What does this PR do ?
This PR introduces an optional parameter "allowTriggerEvents" in KuzzleRequest to allow or not API actions to trigger events and pipes.
In the funnel if a pluginRequest holds this parameter, the request is processed as a normal request otherwise it is treated as usally without triggering events.
How should this be manually tested?
In a project using Kuzzle:
-Set up a custom controller creating a document for example
-Set up a pipe that triggers on the creation of document ('document:beforeCreate/document:afterCreate)
-Send a request to your controller without "allowTriggerEvents": the pipe shouldn't trigger
-Send a request to your controller with allowTriggerEvents:true the pipe should trigger.
Other changes
With this process the request also triggers statistic counts which it wouldn't have in the normal pluginRequest execution