forked from memcached/memcached
-
Notifications
You must be signed in to change notification settings - Fork 3
/
sflow_mc.h
54 lines (44 loc) · 1.44 KB
/
sflow_mc.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
#ifndef SFLOW_MC_H
#define SFLOW_MC_H 1
#include "config.h"
//#include "memcached.h"
#include <sys/types.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h> /* for PRIu64 etc. */
#ifdef ENABLE_SFLOW
typedef enum {
SFMC_CMD_OTHER = 0,
SFMC_CMD_SET = 1,
SFMC_CMD_ADD = 2,
SFMC_CMD_REPLACE = 3,
SFMC_CMD_APPEND = 4,
SFMC_CMD_PREPEND = 5,
SFMC_CMD_CAS = 6,
SFMC_CMD_GET = 7,
SFMC_CMD_GETS = 8,
SFMC_CMD_INCR = 9,
SFMC_CMD_DECR = 10,
SFMC_CMD_DELETE = 11,
SFMC_CMD_STATS = 12,
SFMC_CMD_FLUSH = 13,
SFMC_CMD_VERSION = 14,
SFMC_CMD_QUIT = 15,
SFMC_CMD_TOUCH = 16,
} SFLMemcache_cmd;
void sflow_init(void);
void sflow_sample_test(struct conn *c);
void sflow_sample(SFLMemcache_cmd cmd, struct conn *c, const void *key, size_t keylen, uint32_t nkeys, size_t value_bytes, int status);
#define SFLOW_INIT() sflow_init()
#define SFLOW_SAMPLE_TEST(c) sflow_sample_test(c)
#define SFLOW_SAMPLE(cmd, c, key, keylen, nkeys, bytes, status) \
do { \
if(unlikely((c)->sflow_start_time.tv_sec)) { \
sflow_sample((cmd), (c), (key), (keylen), (nkeys), (bytes), (status)); \
} \
} while(0)
#else
#define SFLOW_INIT()
#define SFLOW_SAMPLE_TEST(c)
#define SFLOW_SAMPLE(cmd, c, key, keylen, nkeys, bytes, slab_op)
#endif /* ENABLE_SFLOW */
#endif /* SFLOW_MC_H */