-
Notifications
You must be signed in to change notification settings - Fork 0
prepare PR 1 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
prepare PR 1 #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,62 @@ | ||
| use std::time::Duration; | ||
| use std::{path::PathBuf, time::Duration}; | ||
|
|
||
| #[derive(Debug, Default, serde::Deserialize, Clone, PartialEq)] | ||
| pub struct EntityCachingConfig { | ||
| pub enabled: Option<bool>, | ||
|
|
||
| #[serde(default)] | ||
| pub storage: EntityCachingStorage, | ||
|
|
||
| #[serde(default)] | ||
| pub redis: Option<EntityCachingRedisConfig>, | ||
|
|
||
| /// The ttl to store cache entries with. Defaults to 60s | ||
| #[serde(deserialize_with = "duration_str::deserialize_option_duration", default)] | ||
| pub ttl: Option<Duration>, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Default, PartialEq, serde::Deserialize)] | ||
| #[serde(rename_all = "lowercase")] | ||
| pub enum EntityCachingStorage { | ||
| #[default] | ||
| Memory, | ||
| Redis, | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, serde::Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct EntityCachingRedisConfig { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Suggestion |
||
| #[serde(default = "EntityCachingRedisConfig::default_url")] | ||
| pub url: url::Url, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⚡ Suggestion |
||
| #[serde(default = "EntityCachingRedisConfig::default_key_prefix")] | ||
| pub key_prefix: String, | ||
| pub tls: Option<EntityCachingRedisTlsConfig>, | ||
| } | ||
|
|
||
| impl Default for EntityCachingRedisConfig { | ||
| fn default() -> Self { | ||
| Self { | ||
| url: Self::default_url(), | ||
| key_prefix: Self::default_key_prefix(), | ||
| tls: None, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl EntityCachingRedisConfig { | ||
| fn default_url() -> url::Url { | ||
| url::Url::parse("redis://localhost:6379").expect("must be correct") | ||
| } | ||
|
|
||
| fn default_key_prefix() -> String { | ||
| String::from("grafbase-cache") | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Default, serde::Deserialize)] | ||
| #[serde(deny_unknown_fields)] | ||
| pub struct EntityCachingRedisTlsConfig { | ||
| pub cert: Option<PathBuf>, | ||
| pub key: Option<PathBuf>, | ||
| pub ca: Option<PathBuf>, | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚡ Suggestion
Ensure that the handling of additional fields in the pattern matching is consistent across all usages to avoid potential bugs.