Closed rcorre closed 3 months ago
A good suggestion! But I have some questions about your use case:
As you know, data_callback_func
is a function that requires user to provide/implement, it will only be called in the libcurl callback writeDataCallback
https://github.com/kubernetes-client/c/blob/c223563bda143b3ca9e38cbee5782b37cad040a3/kubernetes/src/apiClient.c#L471
How the new userp-for-data_callback_func
is passed into writeDataCallback
?
And I think in the customized data_callback_func
, you can call a handler function, e.g.
https://github.com/kubernetes-client/c/blob/c223563bda143b3ca9e38cbee5782b37cad040a3/examples/watch_list_pod/main.c#LL68C3-L68C3
How the new userp-for-data_callback_func is passed into writeDataCallback ?
As the data_callback_func
is a field on the apiClient
, the user pointer could be another field there, so you'd have something like:
apiClient->data_callback_func(apiClient->callbackData, &apiClient->dataReceived, &apiClient->dataReceivedLen);
And I think in the customized data_callback_func, you can call a handler function
There's still no way to get data out of the handler you pass in. In the example on_pod_event_comes
just prints the value, but if you wanted to put it in some data structure, or a database, there's no way to do that without using a global.
I understand. This is a nice addition to data_callback_func
.
Would you like to create a PR to implement your idea ?
And I have a suggestion for the usage (put the callbackData in the last place):
apiClient->data_callback_func(&apiClient->dataReceived, &apiClient->dataReceivedLen, apiClient->callbackUserData);
This code change needs to be committed into the upstream https://github.com/OpenAPITools/openapi-generator/blob/afca85acf577c4117e6eda650d2e228726b57f5c/modules/openapi-generator/src/main/resources/C-libcurl/apiClient.h.mustache#L27 first.
FYI https://github.com/OpenAPITools/openapi-generator/pull/7974
Thanks! I'm currently waiting on legal approval from my company to sign the CLA.
The Kubernetes project currently lacks enough contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.
This bot triages un-triaged issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.
This bot triages issues according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/reopen
/remove-lifecycle rotten
Please send feedback to sig-contributor-experience at kubernetes/community.
/close not-planned
@k8s-triage-robot: Closing this issue, marking it as "Not Planned".
data_callback_func
takes avoid**
for the incoming data, and along *
for the data length. This is fine if you just want to print the object like the examples do, but what if you want to store the data in some structure, or pass it to another component?It would be useful to have a "user pointer" so we could pass in our own store/component to handle the data, similar to how the writeDataCallback passed to curl has a
userp
field.