diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index 3b382f72d58b4..972ab4c61dd3d 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -752,6 +752,7 @@ name = "common-types"
version = "0.1.0"
dependencies = [
"serde",
+ "sqlx",
"time",
"uuid",
]
@@ -1104,7 +1105,9 @@ dependencies = [
"envconfig",
"health",
"metrics",
+ "moka",
"rdkafka",
+ "sqlx",
"thiserror",
"tokio",
"tracing",
@@ -2336,6 +2339,26 @@ dependencies = [
"windows-sys 0.48.0",
]
+[[package]]
+name = "moka"
+version = "0.12.8"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32cf62eb4dd975d2dde76432fb1075c49e3ee2331cf36f1f8fd4b66550d32b6f"
+dependencies = [
+ "crossbeam-channel",
+ "crossbeam-epoch",
+ "crossbeam-utils",
+ "once_cell",
+ "parking_lot",
+ "quanta 0.12.2",
+ "rustc_version",
+ "smallvec",
+ "tagptr",
+ "thiserror",
+ "triomphe",
+ "uuid",
+]
+
[[package]]
name = "native-tls"
version = "0.2.11"
@@ -2910,7 +2933,7 @@ dependencies = [
"futures",
"health",
"metrics",
- "quick_cache",
+ "moka",
"serde",
"serde_json",
"serve-metrics",
@@ -2976,18 +2999,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "quick_cache"
-version = "0.6.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "27a893a83255c587d31137bc7e350387b49267b0deac44120fd8fa8bd0d61645"
-dependencies = [
- "ahash",
- "equivalent",
- "hashbrown 0.14.3",
- "parking_lot",
-]
-
[[package]]
name = "quote"
version = "1.0.35"
@@ -3296,6 +3307,15 @@ version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
+[[package]]
+name = "rustc_version"
+version = "0.4.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
+dependencies = [
+ "semver",
+]
+
[[package]]
name = "rustix"
version = "0.37.27"
@@ -4000,6 +4020,12 @@ dependencies = [
"libc",
]
+[[package]]
+name = "tagptr"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7b2093cf4c8eb1e67749a6762251bc9cd836b6fc171623bd0a9d324d37af2417"
+
[[package]]
name = "tempfile"
version = "3.10.0"
@@ -4386,6 +4412,12 @@ dependencies = [
"tracing-log",
]
+[[package]]
+name = "triomphe"
+version = "0.1.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "859eb650cfee7434994602c3a68b25d77ad9e68c8a6cd491616ef86661382eb3"
+
[[package]]
name = "try-lock"
version = "0.2.5"
diff --git a/rust/Cargo.toml b/rust/Cargo.toml
index 18a33a9b41185..083f875bbf7b7 100644
--- a/rust/Cargo.toml
+++ b/rust/Cargo.toml
@@ -91,5 +91,5 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
url = { version = "2.5.0 " }
uuid = { version = "1.6.1", features = ["v7", "serde"] }
neon = "1"
-quick_cache = "0.6.5"
+moka = {version = "0.12.8", features = ["sync"] }
ahash = "0.8.11"
\ No newline at end of file
diff --git a/rust/common/types/Cargo.toml b/rust/common/types/Cargo.toml
index 4346b543d038c..17f74c8b501df 100644
--- a/rust/common/types/Cargo.toml
+++ b/rust/common/types/Cargo.toml
@@ -9,4 +9,5 @@ workspace = true
[dependencies]
serde = { workspace = true }
uuid = { workspace = true }
-time = {workspace = true }
\ No newline at end of file
+time = { workspace = true }
+sqlx = { workspace = true }
\ No newline at end of file
diff --git a/rust/common/types/README.md b/rust/common/types/README.md
index 97004f3882fe6..9c185f9c4cd60 100644
--- a/rust/common/types/README.md
+++ b/rust/common/types/README.md
@@ -1,3 +1,3 @@
# Common types
-For types used across our projects, like events, persons, etc. Each time you go to copy a type from somewhere, put it here instead.
\ No newline at end of file
+For types used across our projects, like events, persons, etc. Each time you go to copy a type from somewhere, put it here instead.
diff --git a/rust/common/types/src/lib.rs b/rust/common/types/src/lib.rs
index a9df0571b4782..79afc98c1e83f 100644
--- a/rust/common/types/src/lib.rs
+++ b/rust/common/types/src/lib.rs
@@ -1,4 +1,8 @@
mod event;
+mod team;
// Events
pub use event::CapturedEvent;
+
+// Teams
+pub use team::Team;
diff --git a/rust/common/types/src/team.rs b/rust/common/types/src/team.rs
new file mode 100644
index 0000000000000..c67cdb53b07cc
--- /dev/null
+++ b/rust/common/types/src/team.rs
@@ -0,0 +1,63 @@
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, Debug, Deserialize, Serialize, sqlx::FromRow)]
+pub struct Team {
+ pub id: i32,
+ pub name: String,
+ pub api_token: String,
+}
+
+// We use query_as functions here rather than macros to avoid having to wrangle sqlx... TODO, be better
+// about that.
+impl Team {
+ pub async fn by_token<'c, E>(executor: E, token: &str) -> Result