Skip to content

Commit

Permalink
feat: add moka backend and config
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyrix126 committed Jun 12, 2024
1 parent 91ab814 commit 4d13e9c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ edition = "2021"

[dependencies]
confy = "0.6"
serde = { version = "1", features = ["derive"]}
anyhow = "1.0"
tracing = "0.1"
tracing-subscriber = "0.3"
axum = {version="0.7", default-features= false, features= ["tokio", "http2"] }
tokio = {version="1", default-features=false, features= ["rt-multi-thread", "sync"] }
reqwest = {version="0.12", default-features=false, features=["rustls-tls", "http2"]}
url = {version="2.5.0", features=["serde"]}
moka = {version="0.12", features=["future"]}
ahash = "0.8"
25 changes: 25 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::time::Duration;

use reqwest::Url;
use serde::{Deserialize, Serialize};
/// configuration struct.
/// Example:
/// listen_port: 9834,
/// endpoints: [("/api1", "127.0.0.1:3998")]
#[derive(Serialize, Deserialize, Default)]
pub struct Config {
/// port to which Mnemosyne will listen for incoming requests.
pub listen_port: u16,
/// String is the path mnemosyne will accept request and redirect them to Url
pub endpoints: Vec<(String, Url)>,
/// cache backend configuration
pub cache: CacheConfig,
}

#[derive(Serialize, Deserialize, Default)]
pub struct CacheConfig {
/// cache expiration after last request
pub expiration: Duration,
/// maximum cache entry
pub max_entry: u64,
}

0 comments on commit 4d13e9c

Please sign in to comment.