Skip to content

Commit

Permalink
proxy: recognize but ignore the 3 new redis message types
Browse files Browse the repository at this point in the history
  • Loading branch information
knz committed Dec 19, 2024
1 parent b135194 commit e50fb1e
Showing 1 changed file with 57 additions and 1 deletion.
58 changes: 57 additions & 1 deletion proxy/src/redis/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,27 @@ pub(crate) enum Notification {
AllowedIpsUpdate {
allowed_ips_update: AllowedIpsUpdate,
},
#[serde(
rename = "/block_public_or_vpc_access_updated",
deserialize_with = "deserialize_json_string"
)]
BlockPublicOrVpcAccessUpdate {
block_public_or_vpc_access_update: BlockPublicOrVpcAccessUpdate,
},
#[serde(
rename = "/allowed_vpc_endpoints_updated_for_org",
deserialize_with = "deserialize_json_string"
)]
AllowedVpcEndpointsUpdateForOrg {
allowed_vpc_endpoints_update_for_org: AllowedVpcEndpointsUpdateForOrg,
},
#[serde(
rename = "/allowed_vpc_endpoints_updated_for_projects ",
deserialize_with = "deserialize_json_string"
)]
AllowedVpcEndpointsUpdateForProjects {
allowed_vpc_endpoints_update_for_projects: AllowedVpcEndpointsUpdateForProjects,
},
#[serde(
rename = "/password_updated",
deserialize_with = "deserialize_json_string"
Expand All @@ -51,6 +72,26 @@ pub(crate) enum Notification {
pub(crate) struct AllowedIpsUpdate {
project_id: ProjectIdInt,
}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]

pub(crate) struct BlockPublicOrVpcAccessUpdate {
project_id: ProjectIdInt,
}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]

pub(crate) struct AllowedVpcEndpointsUpdateForOrg {
// TODO: change type once the implementation is more fully fledged.
// See e.g. https://github.com/neondatabase/neon/pull/10073.
account_id: ProjectIdInt,
}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub(crate) struct AllowedVpcEndpointsUpdateForProjects {
project_ids: Vec<ProjectIdInt>,
}

#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub(crate) struct PasswordUpdate {
project_id: ProjectIdInt,
Expand Down Expand Up @@ -164,7 +205,11 @@ impl<C: ProjectInfoCache + Send + Sync + 'static> MessageHandler<C> {
}
}
}
Notification::AllowedIpsUpdate { .. } | Notification::PasswordUpdate { .. } => {
Notification::AllowedIpsUpdate { .. }
| Notification::PasswordUpdate { .. }
| Notification::BlockPublicOrVpcAccessUpdate { .. }
| Notification::AllowedVpcEndpointsUpdateForOrg { .. }
| Notification::AllowedVpcEndpointsUpdateForProjects { .. } => {
invalidate_cache(self.cache.clone(), msg.clone());
if matches!(msg, Notification::AllowedIpsUpdate { .. }) {
Metrics::get()
Expand All @@ -177,6 +222,8 @@ impl<C: ProjectInfoCache + Send + Sync + 'static> MessageHandler<C> {
.redis_events_count
.inc(RedisEventsCount::PasswordUpdate);
}
// TODO: add additional metrics for the other event types.

// It might happen that the invalid entry is on the way to be cached.
// To make sure that the entry is invalidated, let's repeat the invalidation in INVALIDATION_LAG seconds.
// TODO: include the version (or the timestamp) in the message and invalidate only if the entry is cached before the message.
Expand All @@ -203,6 +250,15 @@ fn invalidate_cache<C: ProjectInfoCache>(cache: Arc<C>, msg: Notification) {
password_update.role_name,
),
Notification::Cancel(_) => unreachable!("cancel message should be handled separately"),
Notification::BlockPublicOrVpcAccessUpdate { .. } => {
// https://github.com/neondatabase/neon/pull/10073
}
Notification::AllowedVpcEndpointsUpdateForOrg { .. } => {
// https://github.com/neondatabase/neon/pull/10073
}
Notification::AllowedVpcEndpointsUpdateForProjects { .. } => {
// https://github.com/neondatabase/neon/pull/10073
}
}
}

Expand Down

0 comments on commit e50fb1e

Please sign in to comment.