Skip to content

Commit

Permalink
sled can create directly in a temporary file
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal authored and FlorentinDUBOIS committed Jul 13, 2022
1 parent 8ffca7f commit f12bacb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ regex = "1.1"
cookie-factory = "^0.3"
hpack = "^0.3"
sled = "0.34"
tempfile = "^3"

[dev-dependencies]
tiny_http = "^0.8"
Expand Down
9 changes: 5 additions & 4 deletions lib/src/metrics/local_drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pub struct LocalDrain {
pub prefix: String,
pub created: Instant,
pub db: sled::Db,
pub data_dir: tempfile::TempDir,
pub data: BTreeMap<String, AggregatedMetric>,
metrics: BTreeMap<String, (MetricMeta, MetricKind)>,
use_tagged_metrics: bool,
Expand All @@ -115,13 +114,15 @@ pub struct LocalDrain {

impl LocalDrain {
pub fn new(prefix: String) -> Self {
let data_dir = tempfile::TempDir::new().unwrap();
let db = sled::open(data_dir.path()).unwrap();
let db = sled::Config::new()
.temporary(true)
.mode(sled::Mode::LowSpace)
.open()
.unwrap();

LocalDrain {
prefix,
created: Instant::now(),
data_dir,
db,
metrics: BTreeMap::new(),
data: BTreeMap::new(),
Expand Down

0 comments on commit f12bacb

Please sign in to comment.