Skip to main content

logforth_append_async/
lib.rs

1// Copyright 2024 FastLabs Developers
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! A composable appender, logging and flushing asynchronously.
16
17#![cfg_attr(docsrs, feature(doc_cfg))]
18#![deny(missing_docs)]
19
20use logforth_core::kv;
21use logforth_core::record::RecordOwned;
22
23mod append;
24mod channel;
25mod state;
26mod worker;
27
28pub use self::append::Async;
29pub use self::append::AsyncBuilder;
30
31enum Task {
32    Log {
33        record: Box<RecordOwned>,
34        diags: Vec<(kv::KeyOwned, kv::ValueOwned)>,
35    },
36    Flush {
37        done: oneshot::Sender<()>,
38    },
39}
40
41#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
42enum Overflow {
43    /// Blocks until the channel is not full.
44    Block,
45    /// Drops the incoming operation.
46    DropIncoming,
47}