adamdebreceni commented on a change in pull request #955: URL: https://github.com/apache/nifi-minifi-cpp/pull/955#discussion_r561008200
########## File path: libminifi/include/core/logging/internal/LogBuffer.h ########## @@ -0,0 +1,62 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include <memory> +#include <utility> + +#include "io/BufferStream.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace core { +namespace logging { +namespace internal { + +class LogBuffer { + public: + LogBuffer() = default; + explicit LogBuffer(std::unique_ptr<io::BufferStream> buffer): buffer_{std::move(buffer)} {} + + static LogBuffer allocate(size_t max_size) { + LogBuffer instance{utils::make_unique<io::BufferStream>()}; + instance.buffer_->reserve(max_size * 3 / 2); Review comment: `max_size` is a soft limit, i.e. reaching `max_size` is an indicator that that block should be compressed and committed (or for the compressed blocks to be discarded), we cannot guarantee that only `max_size` content is written to the buffer (not unless we plan on compressing in and blocking the logger thread), since `max_size` is the "trigger limit", presumable each block would contain (at the trigger point) a little more than `max_size` content ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
