From: Casey Bodley Date: Wed, 10 Oct 2018 19:11:38 +0000 (-0400) Subject: rgw: add rgw::putobj::DataProcessor interface and Pipe X-Git-Tag: v14.1.0~1156^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=504b7d9c2128a8cd6d018d89a367bb2e96e34a96;p=ceph.git rgw: add rgw::putobj::DataProcessor interface and Pipe 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 --- diff --git a/src/rgw/rgw_putobj.h b/src/rgw/rgw_putobj.h new file mode 100644 index 000000000000..0c8995443ed6 --- /dev/null +++ b/src/rgw/rgw_putobj.h @@ -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