This is an automated email from the ASF dual-hosted git repository.
rlenferink pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/celix.git
The following commit(s) were added to refs/heads/develop by this push:
new f519ec6 Made discovery endpoint poller timeout configurable
f519ec6 is described below
commit f519ec6fe2df9d741b4caaeccaafbc2d499758dc
Author: Roy Lenferink <[email protected]>
AuthorDate: Mon Jun 17 15:07:57 2019 +0200
Made discovery endpoint poller timeout configurable
---
.../include/endpoint_discovery_poller.h | 2 ++
.../src/endpoint_discovery_poller.c | 13 +++++++++++--
bundles/remote_services/examples/CMakeLists.txt | 22 +++++++++++++++++-----
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git
a/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
b/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
index 3c537f1..ac8324f 100644
---
a/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
+++
b/bundles/remote_services/discovery_common/include/endpoint_discovery_poller.h
@@ -43,6 +43,8 @@ struct endpoint_discovery_poller {
celix_thread_t pollerThread;
unsigned int poll_interval;
+ unsigned int poll_timeout;
+
volatile bool running;
};
diff --git
a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
index 06ffc42..c481e77 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c
@@ -40,8 +40,10 @@
#define DISCOVERY_POLL_INTERVAL "DISCOVERY_CFG_POLL_INTERVAL"
-#define DEFAULT_POLL_INTERVAL "10"
+#define DEFAULT_POLL_INTERVAL "10" // seconds
+#define DISCOVERY_POLL_TIMEOUT "DISCOVERY_CFG_POLL_TIMEOUT"
+#define DEFAULT_POLL_TIMEOUT "10" // seconds
static void *endpointDiscoveryPoller_performPeriodicPoll(void *data);
celix_status_t endpointDiscoveryPoller_poll(endpoint_discovery_poller_pt
poller, char *url, array_list_pt currentEndpoints);
@@ -72,6 +74,12 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt
discovery, bundle_con
interval = DEFAULT_POLL_INTERVAL;
}
+ const char* timeout = NULL;
+ status = bundleContext_getProperty(context, DISCOVERY_POLL_TIMEOUT,
&timeout);
+ if (!timeout) {
+ timeout = DEFAULT_POLL_TIMEOUT;
+ }
+
const char* endpointsProp = NULL;
status = bundleContext_getProperty(context, DISCOVERY_POLL_ENDPOINTS,
&endpointsProp);
if (!endpointsProp) {
@@ -81,6 +89,7 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt
discovery, bundle_con
char* endpoints = strdup(endpointsProp);
(*poller)->poll_interval = atoi(interval);
+ (*poller)->poll_timeout = atoi(timeout);
(*poller)->discovery = discovery;
(*poller)->running = false;
(*poller)->entries = hashMap_create(utils_stringHash, NULL,
utils_stringEquals, NULL);
@@ -358,7 +367,7 @@ static celix_status_t
endpointDiscoveryPoller_getEndpoints(endpoint_discovery_po
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION,
endpointDiscoveryPoller_writeMemory);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 5L);
- curl_easy_setopt(curl, CURLOPT_TIMEOUT, 10L);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, poller->poll_timeout);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
diff --git a/bundles/remote_services/examples/CMakeLists.txt
b/bundles/remote_services/examples/CMakeLists.txt
index 0f8e7a9..1989d5b 100644
--- a/bundles/remote_services/examples/CMakeLists.txt
+++ b/bundles/remote_services/examples/CMakeLists.txt
@@ -48,15 +48,27 @@ if (RSA_EXAMPLES)
add_celix_container(remote-services-dfi
NAME "server"
GROUP "remote-services/remote-services-dfi"
- BUNDLES Celix::rsa_discovery_etcd Celix::rsa_topology_manager
Celix::rsa_dfi calculator Celix::shell Celix::shell_tui Celix::log_service
Celix::log_writer_stdout
+ BUNDLES
+ Celix::rsa_discovery_etcd
+ Celix::rsa_topology_manager
+ Celix::rsa_dfi calculator
+ Celix::shell
+ Celix::shell_tui
+ Celix::log_service
+ Celix::log_writer_stdout
)
- add_celix_container("remote-services-dfi-client"
+ add_celix_container(remote-services-dfi-client
NAME "client"
GROUP "remote-services/remote-services-dfi"
- BUNDLES Celix::rsa_topology_manager Celix::rsa_dfi Celix::shell
Celix::shell_tui Celix::log_service Celix::log_writer_stdout calculator_shell
Celix::rsa_discovery_etcd
+ BUNDLES
+ Celix::rsa_topology_manager
+ Celix::rsa_dfi Celix::shell
+ Celix::shell_tui
+ Celix::log_service
+ Celix::log_writer_stdout
+ calculator_shell
+ Celix::rsa_discovery_etcd
)
endif ()
endif (RSA_EXAMPLES)
-
-