]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add rgw::putobj::DataProcessor interface and Pipe
authorCasey Bodley <cbodley@redhat.com>
Wed, 10 Oct 2018 19:11:38 +0000 (15:11 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 15 Oct 2018 21:00:08 +0000 (17:00 -0400)
adds an abstract DataProcessor interface (analogous to
RGWPutObjDataProcessor) that allows processors to be composed into
pipelines, and a Pipe class to support the existing filters for
compression and encryption

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_putobj.h [new file with mode: 0644]

diff --git a/src/rgw/rgw_putobj.h b/src/rgw/rgw_putobj.h
new file mode 100644 (file)
index 0000000..0c89954
--- /dev/null
@@ -0,0 +1,44 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+/*
+ * Ceph - scalable distributed file system
+ *
+ * Copyright (C) 2018 Red Hat, Inc.
+ *
+ * This is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software
+ * Foundation. See file COPYING.
+ *
+ */
+
+#pragma once
+
+#include "include/buffer.h"
+
+namespace rgw::putobj {
+
+// a simple streaming data processing abstraction
+class DataProcessor {
+ public:
+  virtual ~DataProcessor() {}
+
+  // consume a bufferlist in its entirety at the given object offset. an
+  // empty bufferlist is given to request that any buffered data be flushed,
+  // though this doesn't wait for completions
+  virtual int process(bufferlist&& data, uint64_t offset) = 0;
+};
+
+// for composing data processors into a pipeline
+class Pipe : public DataProcessor {
+  DataProcessor *next;
+ public:
+  explicit Pipe(DataProcessor *next) : next(next) {}
+
+  // passes the data on to the next processor
+  int process(bufferlist&& data, uint64_t offset) override {
+    return next->process(std::move(data), offset);
+  }
+};
+
+} // namespace rgw::putobj