Closed clearday4 closed 3 years ago
Hi @clearday4
Now kubernetes-client/c does not support "watch", but I have done some investigation some day before and plan to implement this feature after my current development ( configuration/authentication plugin https://github.com/kubernetes-client/c/issues/4) is done.
My plan is to provide a mechanism to register "watch" callback function to writeDataCallback
(https://github.com/kubernetes-client/c/blob/master/kubernetes/src/apiClient.c)
thank you for your answer.
When do you plan to provide the watch function?
I'm working on this feature and will invite you to discuss the design.
Hi @clearday4
The watch
function is supported by the PR #28 .
Could you please try and check whether it meets your requirement ?
Refer to the example watch_list_pod to get the usage please.
Thank you for your support. It is working well. However, I plan to call the watch function in api. So I try to create thread if I call watch function. At this time, strdup is not working in the thread. Because _GNU_SOURCE is not applied to all files. Please consider to add -D_GNU_SOURCE to CMAKE_C_FLAGS in CMakeLists.txt
And I have a question. When calling watch function, it is blocked by curl_easy_perform() How can I graceful exit if I want to stop the watch?
Hi @clearday4
For this question:
When calling watch function, it is blocked by curl_easy_perform() How can I graceful exit if I want to stop the watch?
Does the parameter timeout
of watch function meet your requirement ?
CoreV1API_listNamespacedPod(apiClient, "default", /*namespace */
NULL, /* pretty */
0, /* allowWatchBookmarks */
NULL, /* continue */
NULL, /* fieldSelector */
NULL, /* labelSelector */
0, /* limit */
NULL, /* resourceVersion */
30, /* timeoutSeconds */ <------------------ Set the timeout
1 /* watch */
);
Please consider to add -D_GNU_SOURCE to CMAKE_C_FLAGS in CMakeLists.txt
The current implementation in kubernetes-client/c is adding #define _GNU_SOURCE
to each source files using strdup
, e.g. kube_config.c, incluster_config.c because CMakeLists.txt comes from openapi-generator/c and I don't want to do lots of changes or it's hard to merge this file after re-generating the c client.
But if there are many files needs add #define _GNU_SOURCE
, we can consider to add it.
Close the issue because watch
function is supported well.
Please refer the examples watch_list_pod and multi_thread
Is there any examples of watch pod lists? please add "watch" function example how to set the resourceVersion and register the callback function. Please give me an available reference. Thanks in advance.