7
7
#include < fstream>
8
8
#include < VertxBus.h>
9
9
#include < json/json.h>
10
- #include " KvdnClient.h "
10
+ #include " KvdnClient.hpp "
11
11
#include < functional>
12
12
13
13
using namespace std ;
@@ -22,14 +22,20 @@ KvdnClient::~KvdnClient() {
22
22
};
23
23
24
24
25
- void KvdnClient::Set (const string &straddr, const string &key, const string &value, VertxBus::ReplyHandler handler) {
25
+ void KvdnClient::set (const string &straddr, const string &key, const string &value, const string &options, VertxBus::ReplyHandler handler) {
26
26
Json::Value hdrs;
27
27
hdrs[" action" ] = " set" ;
28
28
29
29
Json::Value jval;
30
+
30
31
jval[" straddr" ] = straddr;
32
+
31
33
jval[" key" ] = key;
34
+
32
35
jval[" value" ] = value;
36
+
37
+ jval[" options" ] = options;
38
+
33
39
Json::Value opts;
34
40
opts[" NOT" ] = " EMPTY" ;
35
41
jval[" options" ] = opts;
@@ -40,140 +46,158 @@ void KvdnClient::Set(const string &straddr, const string &key, const string &val
40
46
41
47
42
48
this ->kvdnOP (straddr, opdata, handler);
43
- /* VertxBus::ReplyHandler(
44
-
45
- [&](const Json::Value &rjmsg, const VertxBus::VertxBusReplier &rvbr) {
46
-
47
-
48
- std::cout << "in resp" << std::endl;
49
- handler(rjmsg, VertxBus::VertxBusReplier(eb, "questionable reply address?"));
50
- //do we even need a reployer? maybe we need a special type of handler, like an
51
- //kvtxn result handler .... generic Handler<AsyncResult>?
52
- //std::cout << "Received:\n" << writer.write(rjmsg["body"]) << std::endl;
53
- // vertxeb.Close();
54
- }));*/
55
49
}
56
50
57
- void KvdnClient::Submit (const string &straddr, string value, VertxBus::ReplyHandler handler) {
51
+ void KvdnClient::get (const string &straddr, const string &key, const string &options, VertxBus::ReplyHandler handler) {
58
52
Json::Value hdrs;
59
- hdrs[" action" ] = " submit " ;
53
+ hdrs[" action" ] = " get " ;
60
54
61
55
Json::Value jval;
56
+
62
57
jval[" straddr" ] = straddr;
63
- jval[" value" ] = value;
58
+
59
+ jval[" key" ] = key;
60
+
61
+ jval[" options" ] = options;
62
+
64
63
Json::Value opts;
65
64
opts[" NOT" ] = " EMPTY" ;
66
65
jval[" options" ] = opts;
67
66
68
67
Json::Value opdata;
69
68
opdata[" hdrs" ] = hdrs;
70
69
opdata[" jval" ] = jval;
71
- this ->kvdnOP (straddr, opdata, std::move (handler));
72
70
71
+
72
+ this ->kvdnOP (straddr, opdata, handler);
73
73
}
74
74
75
- void KvdnClient::GetKeys (const string &straddr, VertxBus::ReplyHandler handler) {
75
+ void KvdnClient::submit (const string &straddr, const string &value, const string &options, VertxBus::ReplyHandler handler) {
76
76
Json::Value hdrs;
77
- hdrs[" action" ] = " getKeys " ;
77
+ hdrs[" action" ] = " submit " ;
78
78
79
79
Json::Value jval;
80
+
80
81
jval[" straddr" ] = straddr;
82
+
83
+ jval[" value" ] = value;
84
+
85
+ jval[" options" ] = options;
86
+
81
87
Json::Value opts;
82
88
opts[" NOT" ] = " EMPTY" ;
83
89
jval[" options" ] = opts;
84
90
85
91
Json::Value opdata;
86
92
opdata[" hdrs" ] = hdrs;
87
93
opdata[" jval" ] = jval;
88
- this ->kvdnOP (straddr, opdata, std::move (handler));
89
94
90
- }
91
95
96
+ this ->kvdnOP (straddr, opdata, handler);
97
+ }
92
98
93
- void KvdnClient::Get (const string &straddr, string key, VertxBus::ReplyHandler handler) {
99
+ void KvdnClient::getKeys (const string &straddr, const string &options, VertxBus::ReplyHandler handler) {
94
100
Json::Value hdrs;
95
- hdrs[" action" ] = " get " ;
101
+ hdrs[" action" ] = " getKeys " ;
96
102
97
103
Json::Value jval;
104
+
98
105
jval[" straddr" ] = straddr;
99
- jval[" key" ] = key;
100
-
106
+
107
+ jval[" options" ] = options;
108
+
101
109
Json::Value opts;
102
110
opts[" NOT" ] = " EMPTY" ;
103
111
jval[" options" ] = opts;
104
112
105
113
Json::Value opdata;
106
114
opdata[" hdrs" ] = hdrs;
107
115
opdata[" jval" ] = jval;
108
- this ->kvdnOP (straddr, opdata, std::move (handler));
109
116
117
+
118
+ this ->kvdnOP (straddr, opdata, handler);
110
119
}
111
120
112
- void KvdnClient::Query (const string &straddr, string query, VertxBus::ReplyHandler handler) {
121
+ void KvdnClient::del (const string &straddr, const string &key, const string &options, VertxBus::ReplyHandler handler) {
113
122
Json::Value hdrs;
114
- hdrs[" action" ] = " query " ;
123
+ hdrs[" action" ] = " del " ;
115
124
116
125
Json::Value jval;
126
+
117
127
jval[" straddr" ] = straddr;
118
- jval[" query" ] = query;
119
-
128
+
129
+ jval[" key" ] = key;
130
+
131
+ jval[" options" ] = options;
132
+
120
133
Json::Value opts;
121
134
opts[" NOT" ] = " EMPTY" ;
122
135
jval[" options" ] = opts;
123
136
124
137
Json::Value opdata;
125
138
opdata[" hdrs" ] = hdrs;
126
139
opdata[" jval" ] = jval;
127
- this ->kvdnOP (straddr, opdata, std::move (handler));
128
140
129
- }
130
141
131
- void KvdnClient::kvdnOP (const string &straddr, Json::Value opdata, VertxBus::ReplyHandler handler) {
132
- Json::FastWriter fastWriter;
133
-
134
- // std::cout << "fireing kvdn op with data " << fastWriter.write(opdata.asString()) << std::endl;
135
-
136
- std::cout << " issuing kvdn operation" ;
137
- std::string data = opdata.toStyledString ();
138
- std::cout << data;
139
-
140
- eb->Send (" kvdnsvc" , opdata[" jval" ], opdata[" hdrs" ], handler);
142
+ this ->kvdnOP (straddr, opdata, handler);
141
143
}
142
144
143
- void KvdnClient::Delete (const string &straddr, string key, VertxBus::ReplyHandler handler) {
145
+ void KvdnClient::query (const string &straddr, const string &query, const string &options, VertxBus::ReplyHandler handler) {
144
146
Json::Value hdrs;
145
- hdrs[" action" ] = " delete " ; // reserved keyword in c++
147
+ hdrs[" action" ] = " query " ;
146
148
147
149
Json::Value jval;
150
+
148
151
jval[" straddr" ] = straddr;
149
- jval[" key" ] = key;
150
-
152
+
153
+ jval[" query" ] = query;
154
+
155
+ jval[" options" ] = options;
156
+
151
157
Json::Value opts;
152
158
opts[" NOT" ] = " EMPTY" ;
153
159
jval[" options" ] = opts;
154
160
155
161
Json::Value opdata;
156
162
opdata[" hdrs" ] = hdrs;
157
163
opdata[" jval" ] = jval;
158
- this ->kvdnOP (straddr, opdata, std::move (handler));
159
164
165
+
166
+ this ->kvdnOP (straddr, opdata, handler);
160
167
}
161
168
162
- void KvdnClient::Size (const string &straddr, VertxBus::ReplyHandler handler) {
169
+ void KvdnClient::size (const string &straddr, const string &options, VertxBus::ReplyHandler handler) {
163
170
Json::Value hdrs;
164
- hdrs[" action" ] = " size" ; // reserved keyword in c++
171
+ hdrs[" action" ] = " size" ;
165
172
166
173
Json::Value jval;
174
+
167
175
jval[" straddr" ] = straddr;
168
-
176
+
177
+ jval[" options" ] = options;
178
+
169
179
Json::Value opts;
170
180
opts[" NOT" ] = " EMPTY" ;
171
181
jval[" options" ] = opts;
172
182
173
183
Json::Value opdata;
174
184
opdata[" hdrs" ] = hdrs;
175
185
opdata[" jval" ] = jval;
176
- this ->kvdnOP (straddr, opdata, std::move (handler));
177
186
187
+
188
+ this ->kvdnOP (straddr, opdata, handler);
178
189
}
179
190
191
+
192
+
193
+ void KvdnClient::kvdnOP (const string &straddr, Json::Value opdata, VertxBus::ReplyHandler handler) {
194
+ Json::FastWriter fastWriter;
195
+
196
+ // std::cout << "fireing kvdn op with data " << fastWriter.write(opdata.asString()) << std::endl;
197
+
198
+ std::cout << " issuing kvdn operation" ;
199
+ std::string data = opdata.toStyledString ();
200
+ std::cout << data;
201
+
202
+ eb->Send (" kvdnsvc" , opdata[" jval" ], opdata[" hdrs" ], handler);
203
+ }
0 commit comments