-
Notifications
You must be signed in to change notification settings - Fork 2
/
bqip.h
59 lines (43 loc) · 1.33 KB
/
bqip.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef BQIP_H
#define BQIP_H
#include "bolo.h"
#define BQIP_BUFSIZ 8192
/* BQIP packets:
Run <query>, which is <n> octets long
C> Q|<n>|<query>\n
S> R|field1=t:v,t:v,t:v|field2=t:v,t:v,t:v|...<EOF>
Plan <query>, which is <n> octets long
C> P|<n>|<plan>\n
S> R|field1|field2|...<EOF>
List metrics matching the given filter
C> M|<n>|<filter>\n
S> R|cpu:tag=value|mem:tag=value|...<EOF>
*/
struct bqip_buf {
char data[BQIP_BUFSIZ];
size_t len;
};
int bqip_buf_read(struct bqip_buf *b, int fd);
size_t bqip_buf_copy(struct bqip_buf *b, const char *s, size_t len);
int bqip_buf_write(struct bqip_buf *b, int fd);
int bqip_buf_skip(struct bqip_buf *b, size_t len);
int bqip_buf_streamout(struct bqip_buf *b, int fd, const char *s, size_t len);
struct bqip {
int fd;
struct bqip_buf rcvbuf;
struct bqip_buf sndbuf;
struct {
char type;
size_t len;
size_t dot;
char *payload;
} request;
};
void bqip_init(struct bqip *c, int fd);
void bqip_deinit(struct bqip *c);
int bqip_read(struct bqip *c);
int bqip_sendn(struct bqip *c, const void *buf, size_t len);
int bqip_send0(struct bqip *c, const char *s);
int bqip_send_error(struct bqip *c, const char *e);
int bqip_send_tuple(struct bqip *c, struct result *r);
#endif