-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
logger: initial commit of klog functionality for segcache-rs
Adds a new logger which has command logger specific functionality. Adds command logging to pelikan_segcache_rs. Changes to the memcache wire protocol to support providing the necessary context for command logging. Fixes `cas` operation in seg storage implementation.
- Loading branch information
Showing
30 changed files
with
960 additions
and
256 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright 2020 Twitter, Inc. | ||
// Licensed under the Apache License, Version 2.0 | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// constants to define default values | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
// log to the file path | ||
const KLOG_FILE: Option<String> = None; | ||
|
||
// flush interval in milliseconds | ||
const KLOG_INTERVAL: usize = 100; | ||
|
||
// buffer size in bytes | ||
const KLOG_NBUF: usize = 0; | ||
|
||
// log 1 in every N commands | ||
const KLOG_SAMPLE: usize = 100; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// helper functions | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
fn klog_file() -> Option<String> { | ||
KLOG_FILE | ||
} | ||
|
||
fn klog_interval() -> usize { | ||
KLOG_INTERVAL | ||
} | ||
|
||
fn klog_nbuf() -> usize { | ||
KLOG_NBUF | ||
} | ||
|
||
fn klog_sample() -> usize { | ||
KLOG_SAMPLE | ||
} | ||
|
||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// struct definitions | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
pub struct KlogConfig { | ||
#[serde(default = "klog_file")] | ||
klog_file: Option<String>, | ||
#[serde(default = "klog_interval")] | ||
klog_interval: usize, | ||
#[serde(default = "klog_nbuf")] | ||
klog_nbuf: usize, | ||
#[serde(default = "klog_sample")] | ||
klog_sample: usize, | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
// implementation | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
impl KlogConfig { | ||
pub fn file(&self) -> Option<String> { | ||
self.klog_file.clone() | ||
} | ||
|
||
pub fn interval(&self) -> usize { | ||
self.klog_interval | ||
} | ||
|
||
pub fn nbuf(&self) -> usize { | ||
self.klog_nbuf | ||
} | ||
|
||
pub fn sample(&self) -> usize { | ||
self.klog_sample | ||
} | ||
} | ||
|
||
// trait implementations | ||
impl Default for KlogConfig { | ||
fn default() -> Self { | ||
Self { | ||
klog_file: klog_file(), | ||
klog_interval: klog_interval(), | ||
klog_nbuf: klog_nbuf(), | ||
klog_sample: klog_sample(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,7 +121,7 @@ where | |
} | ||
} | ||
Token(_) => { | ||
self.handle_event(&event); | ||
self.handle_event(event); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.