Skip to content

Commit

Permalink
Try to sync multiple slogs
Browse files Browse the repository at this point in the history
  • Loading branch information
jopemachine committed Jan 5, 2024
1 parent 7e97464 commit 78a4077
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 37 deletions.
28 changes: 1 addition & 27 deletions binding/python/raftify.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,10 @@ class AbstractStateMachine(metaclass=abc.ABCMeta):
def decode(cls, packed: bytes) -> "AbstractStateMachine":
raise NotImplementedError

class OverflowStrategy:
""" """

Block: Final[Any]
"""
The caller is blocked until there's enough space.
"""

Drop: Final[Any]
"""
The message gets dropped silently.
"""

DropAndReport: Final[Any]
"""
The message gets dropped and a message with number of dropped is produced once there's
space.
This is the default.
Note that the message with number of dropped messages takes one slot in the channel as
well.
"""

class Logger:
""" """

def __init__(
self, chan_size: int, overflow_strategy: "OverflowStrategy"
) -> None: ...
def __init__(self) -> None: ...
@staticmethod
def default() -> "Logger": ...
@staticmethod
Expand Down
11 changes: 3 additions & 8 deletions binding/python/src/bindings/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,10 @@ pub struct PyLogger {
#[pymethods]
impl PyLogger {
#[new]
pub fn new(chan_size: usize, overflow_strategy: &PyOverflowStrategy) -> Self {
pub fn new() -> Self {
let decorator = slog_term::TermDecorator::new().build();
let drain = slog_term::FullFormat::new(decorator).build().fuse();

let drain = slog_async::Async::new(drain)
.chan_size(chan_size)
.overflow_strategy(overflow_strategy.0)
.build()
.fuse();
let drain = slog_term::CompactFormat::new(decorator).build();
let drain = std::sync::Mutex::new(drain).fuse();

let logger = slog::Logger::root(drain, o!());

Expand Down
4 changes: 2 additions & 2 deletions harness/src/raft_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ pub static RAFTS: Lazy<Mutex<HashMap<u64, Raft>>> = Lazy::new(|| Mutex::new(Hash

fn build_logger(node_id: u64) -> slog::Logger {
let decorator = slog_term::TermDecorator::new().build();
let drain = slog_term::FullFormat::new(decorator).build().fuse();
let drain = slog_async::Async::new(drain).build().fuse();
let drain = slog_term::CompactFormat::new(decorator).build();
let drain = std::sync::Mutex::new(drain).fuse();

let mut builder = LogBuilder::new(drain);
builder = builder.filter(None, slog::FilterLevel::Debug);
Expand Down

0 comments on commit 78a4077

Please sign in to comment.