summaryrefslogtreecommitdiff
path: root/data.c
diff options
context:
space:
mode:
authordefault <nobody@localhost>2023-01-31 21:03:59 +0100
committerdefault <nobody@localhost>2023-01-31 21:03:59 +0100
commit0233d732485a546db829696ad082d7941725f604 (patch)
treeff1bb05414f9efc22c2e6d0346350fa84eb24e5e /data.c
parentcabbdbe20980ba4e1c106c8982f10860d52b339b (diff)
Started rewriting the queue.
Diffstat (limited to 'data.c')
-rw-r--r--data.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/data.c b/data.c
index 6d9ade1..a426957 100644
--- a/data.c
+++ b/data.c
@@ -1318,19 +1318,32 @@ static xs_dict *_enqueue_put(const char *fn, xs_dict *msg)
}
-void enqueue_input(snac *snac, char *msg, char *req, int retries)
-/* enqueues an input message */
+static xs_dict *_new_qmsg(const char *type, const xs_dict *msg, int retries)
+/* creates a queue message */
{
int qrt = xs_number_get(xs_dict_get(srv_config, "queue_retry_minutes"));
xs *ntid = tid(retries * 60 * qrt);
- xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
- xs *qmsg = xs_dict_new();
xs *rn = xs_number_new(retries);
- qmsg = xs_dict_append(qmsg, "type", "input");
+ xs_dict *qmsg = xs_dict_new();
+
+ qmsg = xs_dict_append(qmsg, "type", type);
qmsg = xs_dict_append(qmsg, "message", msg);
- qmsg = xs_dict_append(qmsg, "req", req);
qmsg = xs_dict_append(qmsg, "retries", rn);
+ qmsg = xs_dict_append(qmsg, "ntid", ntid);
+
+ return qmsg;
+}
+
+
+void enqueue_input(snac *snac, char *msg, char *req, int retries)
+/* enqueues an input message */
+{
+ xs *qmsg = _new_qmsg("input", msg, retries);
+ char *ntid = xs_dict_get(qmsg, "ntid");
+ xs *fn = xs_fmt("%s/queue/%s.json", snac->basedir, ntid);
+
+ qmsg = xs_dict_append(qmsg, "req", req);
qmsg = _enqueue_put(fn, qmsg);