-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Template actions invoked more than one time in a request #213
Comments
@bojand could you take a look at this? maybe we are doing something wrong here and haven't noticed it yet |
Hello, it would have been helpful to post the proto definition, as I am not sure if I am understanding the issue and question correctly. But if I am understanding it right, the entire request message is like the JSON posted above. Given that, every call will get new template data and be filled with it. That is every request gets new data, new UUID in your case. We do not generate new template values for each occurrence of the template variable within the template. Hope this makes the distinction clear. {
"SerieID": "{{.UUID}}",
"Time": "{{.Timestamp}}",
"Events": [
{
"EventID": "{{.UUID}}",
"EventType": "credit",
"ObjectKey": "f95f8288-8f1f-4338-bb68-53a1cd61c25f"
},
{
"EventID": "{{.UUID}}",
"EventType": "debit",
"ObjectKey": "75221e12-bccb-4010-ac3e-41b0aa5f9dad"
}
]
} First call might get data like: {
"SerieID": "6d3a9ab1-7310-4964-8338-fdeb8c4b960f",
"Time": "{{.Timestamp}}",
"Events": [
{
"EventID": "6d3a9ab1-7310-4964-8338-fdeb8c4b960f",
"EventType": "credit",
"ObjectKey": "f95f8288-8f1f-4338-bb68-53a1cd61c25f"
},
{
"EventID": "6d3a9ab1-7310-4964-8338-fdeb8c4b960f",
"EventType": "debit",
"ObjectKey": "75221e12-bccb-4010-ac3e-41b0aa5f9dad"
}
]
} 2nd call we create will get new UUID: {
"SerieID": "3ded7836-b860-43cd-b88b-3ae78d67c834",
"Time": "{{.Timestamp}}",
"Events": [
{
"EventID": "3ded7836-b860-43cd-b88b-3ae78d67c834",
"EventType": "credit",
"ObjectKey": "f95f8288-8f1f-4338-bb68-53a1cd61c25f"
},
{
"EventID": "3ded7836-b860-43cd-b88b-3ae78d67c834",
"EventType": "debit",
"ObjectKey": "75221e12-bccb-4010-ac3e-41b0aa5f9dad"
}
]
} and so on... The timestamp would be filled in and I am ignoring it for purpose of demonstration. If you desire a new uuid within a single call that's not something {
"SerieID": "{{newUUID}}",
"Time": "{{.Timestamp}}",
"Events": [
{
"EventID": "{{newUUID}}",
"EventType": "credit",
"ObjectKey": "f95f8288-8f1f-4338-bb68-53a1cd61c25f"
},
{
"EventID": "{{newUUID}}",
"EventType": "debit",
"ObjectKey": "75221e12-bccb-4010-ac3e-41b0aa5f9dad"
}
]
} And the |
Hello @bojand ! Before all, thanks for your attention :-) Yep, this approach, invoking a template function like 'newUUID', is perfect for my use case. I looked at the ghz source, and the template.New function is called inside 'callTemplateData.execute(data string)'. Is there a way to pass a template with 'custom template functions' to ghz, in runner.Run? Something like that:
|
Hello this should be resolved in 0.58.0. Please see the changelog for details. |
I tried to use now, and worked very well :-) Thanks a lot for your help. |
Is your feature request related to a problem? Please describe.
I have a use case where a request is composed of a serie with N events. For example:
EventID must be unique, in a request.
I tried to pass the following parameter to ghz cli:
$ ghz ... -d '{"SerieID":"{{.UUID}}", "Time":"{{.Timestamp}}", "Events":[{"EventID":"{{.UUID}}", "EventType":"credit", "ObjectKey":"f95f8288-8f1f-4338-bb68-53a1cd61c25f"},{"EventID":"{{.UUID}}", "EventType":"debit", "ObjectKey":"75221e12-bccb-4010-ac3e-41b0aa5f9dad"}]}'
In my use case, each EventID must be unique. Reading the docs, I understood that UUID template action is unique for each call invocation/request.
Describe the solution you'd like
In a request, for each "{{.UUID}}", a new UUID is generated.
Describe alternatives you've considered
I tried to implement using the package, with "runner.WithDataFromReader". But WithDataFromReader reads all the stream at the start.
With few series (10K), it's ok, but with 500K, isn't feasible to load all the stream in memory.
The text was updated successfully, but these errors were encountered: