]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_cr_rest: have a raw variant of read resource
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 27 Mar 2017 13:23:05 +0000 (15:23 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 10 Apr 2018 15:03:11 +0000 (08:03 -0700)
Useful when we don't have a json formatted input to send and just
sending raw data

Signed-off-by: Abhishek Lekshmanan <abhishek@suse.com>
src/rgw/rgw_cr_rest.h

index ddeb00af24500276dde59ebf587694c02701bbad..760d3bbecc57b0b1af61d1d5624c4d823fb479cd 100644 (file)
@@ -7,33 +7,31 @@
 #include "rgw_coroutine.h"
 #include "rgw_rest_conn.h"
 
-template <class T>
-class RGWReadRESTResourceCR : public RGWSimpleCoroutine {
+class RGWReadRawRESTResourceCR : public RGWSimpleCoroutine{
+  bufferlist *result;
+ protected:
   RGWRESTConn *conn;
   RGWHTTPManager *http_manager;
   string path;
   param_vec_t params;
-  T *result;
-  bool raw; // raw result, T should be a bufferlist
-  bufferlist* result_bl;
+ public:
   boost::intrusive_ptr<RGWRESTReadResource> http_op;
-
-public:
-  RGWReadRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
-                        RGWHTTPManager *_http_manager, const string& _path,
-                        rgw_http_param_pair *params, T *_result)
-    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
-    path(_path), params(make_param_list(params)), result(_result), raw(false)
+  RGWReadRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                           RGWHTTPManager *_http_manager, const string& _path,
+                           rgw_http_param_pair *params, bufferlist *_result)
+    : RGWSimpleCoroutine(_cct), result(_result), conn(_conn), http_manager(_http_manager),
+    path(_path), params(make_param_list(params))
   {}
 
- RGWReadRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
-                       RGWHTTPManager *_http_manager, const string& _path,
-                       rgw_http_param_pair *params, T *_result, bool _raw, bufferlist* _result_bl)
+ RGWReadRawRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                          RGWHTTPManager *_http_manager, const string& _path,
+                          rgw_http_param_pair *params)
    : RGWSimpleCoroutine(_cct), conn(_conn), http_manager(_http_manager),
-    path(_path), params(make_param_list(params)), result(_result), raw(_raw), result_bl(_result_bl)
+    path(_path), params(make_param_list(params))
   {}
 
-  ~RGWReadRESTResourceCR() override {
+
+  ~RGWReadRawRESTResourceCR() override {
     request_cleanup();
   }
 
@@ -55,16 +53,15 @@ public:
   }
 
 
+
+  virtual int wait_result() {
+    return http_op->wait_bl(result);
+  }
+
   int request_complete() override {
     int ret;
-    if (!raw)
-      ret = http_op->wait(result);
-    else{
-      // forgive me
-      ret = http_op->wait_bl(result_bl);
-      //bl->encode(result);
-    }
 
+    ret = wait_result();
 
     auto op = std::move(http_op); // release ref on return
     if (ret < 0) {
@@ -82,6 +79,24 @@ public:
       http_op = NULL;
     }
   }
+
+};
+
+
+template <class T>
+class RGWReadRESTResourceCR : public RGWReadRawRESTResourceCR {
+  T *result;
+ public:
+ RGWReadRESTResourceCR(CephContext *_cct, RGWRESTConn *_conn,
+                       RGWHTTPManager *_http_manager, const string& _path,
+                       rgw_http_param_pair *params, T *_result)
+   : RGWReadRawRESTResourceCR(_cct, _conn, _http_manager, _path, params), result(_result)
+  {}
+
+  int wait_result() override {
+    return http_op->wait(result);
+  }
+
 };
 
 template <class T>