summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authorGravatar default2022-09-28 20:41:07 +0200
committerGravatar default2022-09-28 20:41:07 +0200
commit2be2c07e9c930fd4582feb3cb02162c8b3785000 (patch)
treeec4f141364de69fb790371e6b8ed2431782e9c98 /data.c
parentIf an actor cannot be retrieved, move the message back to the queue. (diff)
downloadsnac2-2be2c07e9c930fd4582feb3cb02162c8b3785000.tar.gz
snac2-2be2c07e9c930fd4582feb3cb02162c8b3785000.tar.xz
snac2-2be2c07e9c930fd4582feb3cb02162c8b3785000.zip
The input queue also has retries.
Diffstat (limited to 'data.c')
-rw-r--r--data.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/data.c b/data.c
index c4ade59..ee21a98 100644
--- a/data.c
+++ b/data.c
@@ -831,21 +831,24 @@ int static_get(snac *snac, char *id, d_char **data, int *size)
831} 831}
832 832
833 833
834void enqueue_input(snac *snac, char *msg, char *req) 834void enqueue_input(snac *snac, char *msg, char *req, int retries)
835/* enqueues an input message */ 835/* enqueues an input message */
836{ 836{
837 xs *ntid = tid(0); 837 int qrt = xs_number_get(xs_dict_get(srv_config, "queue_retry_minutes"));
838 xs *ntid = tid(retries * 60 * qrt);
838 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid); 839 xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
839 xs *tfn = xs_fmt("%s.tmp", fn); 840 xs *tfn = xs_fmt("%s.tmp", fn);
840 FILE *f; 841 FILE *f;
841 842
842 if ((f = fopen(tfn, "w")) != NULL) { 843 if ((f = fopen(tfn, "w")) != NULL) {
843 xs *qmsg = xs_dict_new(); 844 xs *qmsg = xs_dict_new();
845 xs *rn = xs_number_new(retries);
844 xs *j; 846 xs *j;
845 847
846 qmsg = xs_dict_append(qmsg, "type", "input"); 848 qmsg = xs_dict_append(qmsg, "type", "input");
847 qmsg = xs_dict_append(qmsg, "object", msg); 849 qmsg = xs_dict_append(qmsg, "object", msg);
848 qmsg = xs_dict_append(qmsg, "req", req); 850 qmsg = xs_dict_append(qmsg, "req", req);
851 qmsg = xs_dict_append(qmsg, "retries", rn);
849 852
850 j = xs_json_dumps_pp(qmsg, 4); 853 j = xs_json_dumps_pp(qmsg, 4);
851 854