Merge branch 'master' of tsn:public_html/git/elliptics
[elliptics.git] / include / elliptics / srw.h
blob1063e9594f66222bdb64a09128c0a2f02f927815
1 /*
2 * 2008+ Copyright (c) Evgeniy Polyakov <zbr@ioremap.net>
3 * All rights reserved.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
16 #ifndef __ELLIPTICS_SRW_H
17 #define __ELLIPTICS_SRW_H
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
23 #include <elliptics/core.h>
24 #include <elliptics/packet.h>
26 #define DNET_SPH_FLAGS_SRC_BLOCK (1<<0) /* when set data in @src is valid ID and can be used to send reply data, caller blocks */
27 #define DNET_SPH_FLAGS_REPLY (1<<1) /* this packet is a reply to the blocked request with ID stored in @src */
28 #define DNET_SPH_FLAGS_FINISH (1<<2) /* complete request with ID stored in @src, this packet will unblock client */
30 struct sph {
31 struct dnet_raw_id src; /* reply has to be sent to this id */
32 uint64_t data_size; /* size of text data in @data - located after even string */
33 uint64_t binary_size; /* size of binary data in @data - located after text data */
34 uint64_t flags;
35 int event_size; /* size of the event string - it is located first in @data */
36 int status; /* processing status - negative errno code or zero on success */
37 int key; /* meta-key - used to map header to particular worker, see pool::worker_process() */
38 int src_key; /* blocked client generates this key and waits for it to complete */
39 char data[0];
40 } __attribute__ ((packed));
42 static inline void dnet_convert_sph(struct sph *e)
44 e->data_size = dnet_bswap64(e->data_size);
45 e->binary_size = dnet_bswap64(e->binary_size);
46 e->flags = dnet_bswap64(e->flags);
47 e->event_size = dnet_bswap32(e->event_size);
48 e->status = dnet_bswap32(e->status);
49 e->key = dnet_bswap32(e->key);
50 e->src_key = dnet_bswap32(e->src_key);
53 struct srw_init_ctl {
54 char *config;
57 struct dnet_node;
58 int dnet_srw_update(struct dnet_node *n, int pid);
60 #ifdef __cplusplus
62 #endif
65 #endif /* __ELLIPTICS_SRW_H */