@@ -68,17 +68,37 @@ class KeyValueDBClient {
68
68
Expected<std::optional<ValueTy>> getValueSync (ArrayRef<uint8_t > Key) {
69
69
return getValueSync (toStringRef (Key).str ());
70
70
}
71
+
72
+ using GetValueCb = std::function<void (Expected<std::optional<ValueTy>>)>;
73
+ void getValueAsync (std::string Key, GetValueCb Callback) {
74
+ return getValueAsyncImpl (std::move (Key), std::move (Callback));
75
+ }
76
+ void getValueAsync (ArrayRef<uint8_t > Key, GetValueCb Callback) {
77
+ return getValueAsync (toStringRef (Key).str (), std::move (Callback));
78
+ }
79
+
71
80
Error putValueSync (std::string Key, const ValueTy &Value) {
72
81
return putValueSyncImpl (std::move (Key), Value);
73
82
}
74
83
Error putValueSync (ArrayRef<uint8_t > Key, const ValueTy &Value) {
75
84
return putValueSync (toStringRef (Key).str (), Value);
76
85
}
86
+ void putValueAsync (std::string Key, const ValueTy &Value,
87
+ std::function<void (Error)> Callback) {
88
+ return putValueAsyncImpl (std::move (Key), Value, std::move (Callback));
89
+ }
90
+ void putValueAsync (ArrayRef<uint8_t > Key, const ValueTy &Value,
91
+ std::function<void (Error)> Callback) {
92
+ return putValueAsync (toStringRef (Key).str (), Value, std::move (Callback));
93
+ }
77
94
78
95
protected:
79
96
virtual Expected<std::optional<ValueTy>>
80
97
getValueSyncImpl (std::string Key) = 0 ;
98
+ virtual void getValueAsyncImpl (std::string Key, GetValueCb Callback) = 0;
81
99
virtual Error putValueSyncImpl (std::string Key, const ValueTy &Value) = 0;
100
+ virtual void putValueAsyncImpl (std::string Key, const ValueTy &Value,
101
+ std::function<void (Error)> Callback) = 0;
82
102
83
103
public:
84
104
class GetValueAsyncQueue : public AsyncQueueBase {
@@ -184,17 +204,32 @@ class CASDBClient {
184
204
std::optional<std::string> BlobData;
185
205
std::vector<std::string> Refs;
186
206
};
207
+
187
208
Expected<LoadResponse>
188
209
loadSync (std::string CASID,
189
210
std::optional<std::string> OutFilePath = std::nullopt) {
190
211
return loadSyncImpl (std::move (CASID), std::move (OutFilePath));
191
212
}
213
+
214
+ using LoadCb = std::function<void (Expected<LoadResponse>)>;
215
+ void loadAsync (std::string CASID, std::optional<std::string> OutFilePath,
216
+ LoadCb Callback) {
217
+ return loadAsyncImpl (std::move (CASID), std::move (OutFilePath),
218
+ std::move (Callback));
219
+ }
220
+
192
221
Expected<std::string> saveDataSync (std::string BlobData) {
193
222
return saveDataSyncImpl (std::move (BlobData));
194
223
}
195
224
Expected<std::string> saveFileSync (std::string FilePath) {
196
225
return saveFileSyncImpl (std::move (FilePath));
197
226
}
227
+
228
+ using SaveFileCb = std::function<void (Expected<std::string>)>;
229
+ void saveFileAsync (std::string FilePath, SaveFileCb Callback) {
230
+ return saveFileAsyncImpl (std::move (FilePath), std::move (Callback));
231
+ }
232
+
198
233
Expected<GetResponse>
199
234
getSync (std::string CASID,
200
235
std::optional<std::string> OutFilePath = std::nullopt) {
@@ -212,8 +247,14 @@ class CASDBClient {
212
247
protected:
213
248
virtual Expected<LoadResponse>
214
249
loadSyncImpl (std::string CASID, std::optional<std::string> OutFilePath) = 0 ;
250
+ virtual void loadAsyncImpl (std::string CASID,
251
+ std::optional<std::string> OutFilePath,
252
+ LoadCb Callback) = 0;
253
+
215
254
virtual Expected<std::string> saveDataSyncImpl (std::string BlobData) = 0;
216
255
virtual Expected<std::string> saveFileSyncImpl (std::string FilePath) = 0;
256
+ virtual void saveFileAsyncImpl (std::string FilePath, SaveFileCb Callback) = 0;
257
+
217
258
virtual Expected<GetResponse>
218
259
getSyncImpl (std::string CASID, std::optional<std::string> OutFilePath) = 0 ;
219
260
virtual Expected<std::string> putDataSyncImpl (std::string BlobData,
0 commit comments