forked from nsqio/libnsq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
command.c
43 lines (34 loc) · 807 Bytes
/
command.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <stdio.h>
#include <evbuffsock.h>
void nsq_subscribe(struct Buffer *buf, const char *topic, const char *channel)
{
char b[128];
size_t n;
n = sprintf(b, "SUB %s %s\n", topic, channel);
buffer_add(buf, b, n);
}
void nsq_ready(struct Buffer *buf, int count)
{
char b[16];
size_t n;
n = sprintf(b, "RDY %d\n", count);
buffer_add(buf, b, n);
}
void nsq_finish(struct Buffer *buf, const char *id)
{
char b[48];
size_t n;
n = sprintf(b, "FIN %s\n", id);
buffer_add(buf, b, n);
}
void nsq_requeue(struct Buffer *buf, const char *id, int timeout_ms)
{
char b[128];
size_t n;
n = sprintf(b, "REQ %s %d\n", id, timeout_ms);
buffer_add(buf, b, n);
}
void nsq_nop(struct Buffer *buf)
{
buffer_add(buf, "NOP\n", 4);
}