gboolean http_dd_init(LogPipe *s) { HTTPDestinationDriver *self = (HTTPDestinationDriver *)s; GlobalConfig *cfg = log_pipe_get_config(s); if (self->load_balancer->num_targets == 0) http_load_balancer_add_target(self->load_balancer, HTTP_DEFAULT_URL); if (self->load_balancer->num_targets > 1 && s->persist_name == NULL) { msg_warning("WARNING: your http() driver instance uses multiple urls without persist-name(). " "It is recommended that you set persist-name() in this case as syslog-ng will be " "using the first URL in urls() to register persistent data, such as the disk queue " "name, which might change", evt_tag_str("url", self->load_balancer->targets[0].url)); } /* we need to set up url before we call the inherited init method, so our stats key is correct */ self->url = self->load_balancer->targets[0].url; if (!_setup_auth_header(s)) return FALSE; if (!log_threaded_dest_driver_init_method(s)) return FALSE; log_template_options_init(&self->template_options, cfg); http_load_balancer_set_recovery_timeout(self->load_balancer, self->super.time_reopen); return log_threaded_dest_driver_start_workers(&self->super); }
void http_dd_set_urls(LogDriver *d, GList *urls) { HTTPDestinationDriver *self = (HTTPDestinationDriver *) d; http_load_balancer_drop_all_targets(self->load_balancer); for (GList *l = urls; l; l = l->next) http_load_balancer_add_target(self->load_balancer, l->data); }
static HTTPLoadBalancer * _construct_load_balancer(void) { HTTPLoadBalancer *lb; lb = http_load_balancer_new(); for (gint i = 0; i < NUM_TARGETS; i++) { gchar url[256]; g_snprintf(url, sizeof(url), "http://localhost:%d", 8000 + i); http_load_balancer_add_target(lb, url); } return lb; }