control_plane: implement attach hook

This commit is contained in:
John Spray
2023-08-29 09:35:34 +01:00
parent 265d3b4352
commit 3eff65618d
8 changed files with 169 additions and 46 deletions

View File

@@ -39,3 +39,16 @@ pub struct ValidateResponseTenant {
pub id: TenantId,
pub valid: bool,
}
#[cfg(testing)]
#[derive(Serialize, Deserialize)]
pub struct AttachHookRequest {
tenant_id: TenantId,
pageserver_id: Option<NodeId>,
}
#[cfg(testing)]
#[derive(Serialize, Deserialize)]
pub struct AttachHookResponse {
gen: Option<u32>,
}

View File

@@ -50,7 +50,7 @@ impl Id {
Id::from(tli_buf)
}
fn hex_encode(&self) -> String {
pub fn hex_encode(&self) -> String {
static HEX: &[u8] = b"0123456789abcdef";
let mut buf = vec![0u8; self.0.len() * 2];
@@ -133,6 +133,10 @@ macro_rules! id_newtype {
pub const fn from_array(b: [u8; 16]) -> Self {
$t(Id(b))
}
pub fn hex_encode(&self) -> String {
self.0.hex_encode()
}
}
impl FromStr for $t {