-
Notifications
You must be signed in to change notification settings - Fork 43
(9/5) [nexus] Allow anti-affinity members to be affinity groups #7572
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
Changes from all commits
3bf35a2
1430c4a
daeb2e1
2d65048
4e6362d
f50749d
75869c7
804b2ee
0e8e7fc
c96034c
167a2d8
1882d74
17887d4
5865732
6ab1c67
0cb05b5
9ad2313
56f300a
05ebab7
388b6cd
9da8120
aa9de03
90d41c8
20496ce
a0c4ce4
c39e421
22c3eb0
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 |
---|---|---|
|
@@ -11,6 +11,7 @@ use super::impl_enum_type; | |
use crate::schema::affinity_group; | ||
use crate::schema::affinity_group_instance_membership; | ||
use crate::schema::anti_affinity_group; | ||
use crate::schema::anti_affinity_group_affinity_membership; | ||
use crate::schema::anti_affinity_group_instance_membership; | ||
use crate::typed_uuid::DbTypedUuid; | ||
use chrono::{DateTime, Utc}; | ||
|
@@ -257,3 +258,30 @@ impl From<AntiAffinityGroupInstanceMembership> | |
Self::Instance(member.instance_id.into()) | ||
} | ||
} | ||
|
||
#[derive(Queryable, Insertable, Clone, Debug, Selectable)] | ||
#[diesel(table_name = anti_affinity_group_affinity_membership)] | ||
pub struct AntiAffinityGroupAffinityMembership { | ||
pub anti_affinity_group_id: DbTypedUuid<AntiAffinityGroupKind>, | ||
pub affinity_group_id: DbTypedUuid<AffinityGroupKind>, | ||
} | ||
|
||
impl AntiAffinityGroupAffinityMembership { | ||
pub fn new( | ||
anti_affinity_group_id: AntiAffinityGroupUuid, | ||
affinity_group_id: AffinityGroupUuid, | ||
) -> Self { | ||
Self { | ||
anti_affinity_group_id: anti_affinity_group_id.into(), | ||
affinity_group_id: affinity_group_id.into(), | ||
} | ||
} | ||
} | ||
Comment on lines
+269
to
+279
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. this is maybe a bit goofy of me, but for stuff like this where there's a clear directional relationship (the anti-affinity group is a member of the affinity group),i kinda wonder whether we ought to have a method on let membership = anti_affinity_group_id.is_member_of(affinity_group_id); and have that relationship be clearly stated at the call site? On the other hand, this might just be annoying and deviate from the convention for constructors for no real reason. It's the type of thing I would have reached for in my misspent youth[^1] which makes me kind of leery of this suggestion... [^1] i.e. back when i wrote Scala |
||
|
||
impl From<AntiAffinityGroupAffinityMembership> | ||
for external::AntiAffinityGroupMember | ||
{ | ||
fn from(member: AntiAffinityGroupAffinityMembership) -> Self { | ||
Self::AffinityGroup(member.affinity_group_id.into()) | ||
} | ||
} |
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.
Definitely a fan of making this a separate table, rather than changing the existing table to have nullable instance and anti-affinity group ID fields.