Instead of lengthy blurbs, switch to single-line, machine-readable standardized (https://spdx.dev) license identifiers. The Linux kernel switched long ago, so there is strong precedent. Three cases are handled: AGPL-only, Apache-only, and dual licensed. For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0), reasoning that our changes are extensive enough to apply our license. The changes we applied mechanically with a script, except to licenses/README.md. Closes #9937
59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2018-present ScyllaDB
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#include <seastar/core/iostream.hh>
|
|
#include <seastar/core/temporary_buffer.hh>
|
|
#include "utils/small_vector.hh"
|
|
|
|
#include "seastarx.hh"
|
|
|
|
#pragma once
|
|
|
|
// Accumulates data sent to the memory_data_sink allowing it
|
|
// to be examined later.
|
|
class memory_data_sink_buffers {
|
|
using buffers_type = utils::small_vector<temporary_buffer<char>, 1>;
|
|
buffers_type _bufs;
|
|
size_t _size = 0;
|
|
public:
|
|
size_t size() const { return _size; }
|
|
buffers_type& buffers() { return _bufs; }
|
|
|
|
// Strong exception guarantees
|
|
void put(temporary_buffer<char>&& buf) {
|
|
auto size = buf.size();
|
|
_bufs.emplace_back(std::move(buf));
|
|
_size += size;
|
|
}
|
|
|
|
void clear() {
|
|
_bufs.clear();
|
|
_size = 0;
|
|
}
|
|
};
|
|
|
|
class memory_data_sink : public data_sink_impl {
|
|
memory_data_sink_buffers& _bufs;
|
|
public:
|
|
memory_data_sink(memory_data_sink_buffers& b) : _bufs(b) {}
|
|
virtual future<> put(net::packet data) override {
|
|
abort();
|
|
return make_ready_future<>();
|
|
}
|
|
virtual future<> put(temporary_buffer<char> buf) override {
|
|
_bufs.put(std::move(buf));
|
|
return make_ready_future<>();
|
|
}
|
|
virtual future<> flush() override {
|
|
return make_ready_future<>();
|
|
}
|
|
virtual future<> close() override {
|
|
return make_ready_future<>();
|
|
}
|
|
};
|