Skip to content
This repository

allow ps_to_http to accept a secondary pubsub url #67

Merged
merged 1 commit into from almost 2 years ago

2 participants

Srivatsa Ray Matt Reiferson
Srivatsa Ray

No description provided.

Srivatsa Ray

ready for review @mreiferson @jehiah

Matt Reiferson
Collaborator

@sricola - have you verified this works as intended? This is segfaulting for me.

I tested by:

  1. running this command: ./ps_to_http --pubsub-url=http://127.0.0.1:8090/sub?multipart=0 --secondary-pubsub-url=http://127.0.0.1:8091/sub?multipart=0 --destination-get-url=http://127.0.0.2/%s
  2. killing the pubsub on 8090
ps_to_http/ps_to_http.c
((5 lines not shown))
178 179
     char *address;
179 180
     int port;
180 181
     char *path;
181 182
     
182 183
     option_define_bool("version", OPT_OPTIONAL, 0, NULL, version_cb, VERSION);
183 184
     option_define_str("pubsub_url", OPT_REQUIRED, "http://127.0.0.1:80/sub?multipart=0", &pubsub_url, NULL, "url of pubsub to read from");
  185
+    option_define_str("secondary_pubsub_url", OPT_OPTIONAL, "http://127.0.0.1:80/sub?multipart=0", &secondary_pubsub_url, NULL, "url of pubsub to read from");
1
Matt Reiferson Collaborator
mreiferson added a note June 29, 2012

i actually dont think we want to specify a default here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Matt Reiferson
Collaborator

this should work

squash plz

Srivatsa Ray

ready for merge @mreiferson

Srivatsa Ray

@mreiferson updated

Matt Reiferson mreiferson merged commit 647f67d into from June 29, 2012
Matt Reiferson mreiferson closed this June 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jun 29, 2012
Srivatsa Ray allow ps_to_http to accept a secondary pubsub url 8eb88ef
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 23 additions and 3 deletions. Show diff stats Hide diff stats

  1. 26  ps_to_http/ps_to_http.c
26  ps_to_http/ps_to_http.c
@@ -13,7 +13,7 @@
13 13
 #define _DEBUG(...) do {;} while (0)
14 14
 #endif
15 15
 
16  
-#define VERSION "0.5.1"
  16
+#define VERSION "0.5.2"
17 17
 
18 18
 struct destination_url {
19 19
     char *address;
@@ -175,12 +175,14 @@ void free_destination_urls()
175 175
 int main(int argc, char **argv)
176 176
 {
177 177
     char *pubsub_url;
  178
+    char *secondary_pubsub_url = NULL;
178 179
     char *address;
179 180
     int port;
180 181
     char *path;
181 182
     
182 183
     option_define_bool("version", OPT_OPTIONAL, 0, NULL, version_cb, VERSION);
183 184
     option_define_str("pubsub_url", OPT_REQUIRED, "http://127.0.0.1:80/sub?multipart=0", &pubsub_url, NULL, "url of pubsub to read from");
  185
+    option_define_str("secondary_pubsub_url", OPT_OPTIONAL, NULL, &secondary_pubsub_url, NULL, "url of pubsub to read from");
184 186
     option_define_bool("round_robin", OPT_OPTIONAL, 0, &round_robin, NULL, "write round-robin to destination urls");
185 187
     option_define_str("destination_get_url", OPT_OPTIONAL, NULL, NULL, destination_get_url_cb, "(multiple) url(s) to HTTP GET to\n\t\t\t This URL must contain a %s for the message data\n\t\t\t for a simplequeue use \"http://127.0.0.1:8080/put?data=%s\"");
186 188
     option_define_str("destination_post_url", OPT_OPTIONAL, NULL, NULL, destination_post_url_cb, "(multiple) url(s) to HTTP POST to\n\t\t\t For a pubsub endpoint use \"http://127.0.0.1:8080/pub\"");
@@ -206,18 +208,36 @@ int main(int argc, char **argv)
206 208
         }
207 209
         
208 210
         pubsubclient_run();
209  
-        pubsubclient_free();
210 211
         
211 212
         free(address);
212 213
         free(path);
  214
+        free(pubsub_url);
213 215
     } else {
214 216
         fprintf(stderr, "ERROR: failed to parse pubsub_url\n");
215 217
     }
  218
+    if (secondary_pubsub_url && simplehttp_parse_url(secondary_pubsub_url, strlen(secondary_pubsub_url), &address, &port, &path)) {
  219
+	    pubsubclient_init(address, port, path, process_message_cb, error_cb, NULL);
  220
+
  221
+        if (option_get_int("max_silence") > 0) {
  222
+            _DEBUG("Registering timer.\n");
  223
+            max_silence_time.tv_sec = option_get_int("max_silence");
  224
+            evtimer_set(&silence_ev, silence_cb, NULL);
  225
+            evtimer_add(&silence_ev, &max_silence_time);
  226
+        }
  227
+
  228
+        pubsubclient_run();
  229
+
  230
+        free(address);
  231
+        free(path);
  232
+        free(secondary_pubsub_url);
  233
+    } else {
  234
+        fprintf(stderr, "ERROR: failed to parse secondary_pubsub_url\n");
  235
+    }
216 236
     
217 237
     free_destination_urls();
218 238
     free_async_connection_pool();
219 239
     free_options();
220  
-    free(pubsub_url);
  240
+    pubsubclient_free();
221 241
     
222 242
     return 0;
223 243
 }
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.