aboutsummaryrefslogtreecommitdiff
path: root/pw_log_rpc/logs_rpc.cc
diff options
context:
space:
mode:
Diffstat (limited to 'pw_log_rpc/logs_rpc.cc')
-rw-r--r--pw_log_rpc/logs_rpc.cc79
1 files changed, 0 insertions, 79 deletions
diff --git a/pw_log_rpc/logs_rpc.cc b/pw_log_rpc/logs_rpc.cc
deleted file mode 100644
index 5630429d3..000000000
--- a/pw_log_rpc/logs_rpc.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright 2020 The Pigweed Authors
-//
-// Licensed 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
-//
-// https://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.
-
-#include "pw_log_rpc/logs_rpc.h"
-
-#include "pw_log/log.h"
-#include "pw_log/proto/log.pwpb.h"
-#include "pw_status/try.h"
-
-namespace pw::log_rpc {
-namespace {
-
-// TODO(prashanthsw): Handle dropped messages.
-// Result<ConstByteSpan> GenerateDroppedEntryMessage(ByteSpan encode_buffer,
-// size_t dropped_entries) {
-// pw::log::LogEntry::MemoryEncoder encoder(encode_buffer);
-// encoder.WriteDropped(dropped_entries);
-// if (encoder.status().ok()) {
-// return ConstByteSpan(encoder);
-// }
-// return encoder.status();
-// }
-
-} // namespace
-
-void Logs::Get(ServerContext&, ConstByteSpan, rpc::RawServerWriter& writer) {
- response_writer_ = std::move(writer);
-}
-
-Status Logs::Flush() {
- // If the response writer was not initialized or has since been closed,
- // ignore the flush operation.
- if (!response_writer_.open()) {
- return OkStatus();
- }
-
- // If previous calls to flush resulted in dropped entries, generate a
- // dropped entry message and write it before further log messages.
- // TODO(prashanthsw): Handle dropped messages.
- // if (dropped_entries_ > 0) {
- // ByteSpan payload = response_writer_.PayloadBuffer();
- // Result dropped_log = GenerateDroppedEntryMessage(payload,
- // dropped_entries_); PW_TRY(dropped_log.status());
- // PW_TRY(response_writer_.Write(dropped_log.value()));
- // dropped_entries_ = 0;
- // }
-
- // Write logs to the response writer. An important limitation of this
- // implementation is that if this RPC call fails, the logs are lost -
- // a subsequent call to the RPC will produce a drop count message.
- ByteSpan payload = response_writer_.PayloadBuffer();
- Result possible_logs = log_queue_.PopMultiple(payload);
- PW_TRY(possible_logs.status());
- if (possible_logs.value().entry_count == 0) {
- return OkStatus();
- }
-
- Status status = response_writer_.Write(possible_logs.value().entries);
- if (!status.ok()) {
- // On a failure to send logs, track the dropped entries.
- dropped_entries_ = possible_logs.value().entry_count;
- return status;
- }
-
- return OkStatus();
-}
-
-} // namespace pw::log_rpc