s3:mdssvc: add Elasticsearch backend
[asn/samba.git] / source3 / rpc_server / mdssvc / mdssvc_es.h
1 /*
2    Unix SMB/CIFS implementation.
3    Main metadata server / Spotlight routines / HTTP/ES/JSON backend
4
5    Copyright (C) Ralph Boehme                   2019
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #ifndef _MDSSVC_ES_H_
22 #define _MDSSVC_ES_H_
23
24 #include <jansson.h>
25
26 /*
27  * Some global state
28  */
29 struct mdssvc_es_ctx {
30         struct mdssvc_ctx *mdssvc_ctx;
31         struct cli_credentials *creds;
32         json_t *mappings;
33 };
34
35 /*
36  * Per mdssvc RPC bind state
37  */
38 struct mds_es_ctx {
39         /*
40          * Pointer to higher level mds_ctx
41          */
42         struct mds_ctx *mds_ctx;
43
44         /*
45          * Pointer to our global context
46          */
47         struct mdssvc_es_ctx *mdssvc_es_ctx;
48
49         /*
50          * The HTTP connection handle to the ES server
51          */
52         struct http_conn *http_conn;
53
54         /*
55          * List of pending searches
56          */
57         struct sl_es_search *searches;
58 };
59
60 /* Per search request */
61 struct sl_es_search {
62         /*
63          * List pointers
64          */
65         struct sl_es_search *prev, *next;
66
67         /*
68          * Search is being executed. Only the list head can be pending.
69          */
70         bool pending;
71
72         /*
73          * Shorthand to our tevent context
74          */
75         struct tevent_context *ev;
76
77         /*
78          * Pointer to the RPC connection ctx the request is using
79          */
80         struct mds_es_ctx *mds_es_ctx;
81
82         /*
83          * The upper mdssvc.c level query context
84          */
85         struct sl_query *slq;
86
87         /*
88          * Maximum number of results we process and total number of
89          * results of a query.
90          */
91         size_t total;
92         size_t max;
93
94         /*
95          * For paging results
96          */
97         size_t from;
98         size_t size;
99
100         /*
101          * The translated Es query
102          */
103         char *es_query;
104 };
105
106 extern struct mdssvc_backend mdsscv_backend_es;
107
108 #endif /* _MDSSVC_ES_H_ */