fix(protocol): fence gateway work recovery
This commit is contained in:
+58
-28
@@ -1,6 +1,6 @@
|
||||
// Code generated by tools/generate.py; DO NOT EDIT.
|
||||
#![allow(non_snake_case)]
|
||||
pub const SCHEMA_SHA256: &str = "614fa11dd1f49b8e10bf21b8c10eadbc1468d16bfcc6ed0a26d29671a5e61300";
|
||||
pub const SCHEMA_SHA256: &str = "8c1ed430127cf5774a919f14ff4770b2509d322c8518bf30c412e1e89eeffced";
|
||||
pub const CURRENT_WIRE_VERSION: &str = "2";
|
||||
pub const N_MINUS_1_WIRE_VERSION: &str = "1";
|
||||
pub const N_MINUS_2_WIRE_VERSION: &str = "0";
|
||||
@@ -1055,14 +1055,15 @@ pub struct GatewayQualityAck {
|
||||
reconnectSequence: i64,
|
||||
operationId: String,
|
||||
revision: i64,
|
||||
leaseGeneration: i64,
|
||||
outcome: String,
|
||||
currentAppliedRevision: i64,
|
||||
currentAppliedRevision: Option<i64>,
|
||||
failureCode: Option<String>,
|
||||
}
|
||||
|
||||
impl GatewayQualityAck {
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String, revision: i64, outcome: String, currentAppliedRevision: i64, failureCode: Option<String>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId, revision, outcome, currentAppliedRevision, failureCode };
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String, revision: i64, leaseGeneration: i64, outcome: String, currentAppliedRevision: Option<i64>, failureCode: Option<String>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId, revision, leaseGeneration, outcome, currentAppliedRevision, failureCode };
|
||||
value.validate()?;
|
||||
Ok(value)
|
||||
}
|
||||
@@ -1080,12 +1081,18 @@ impl GatewayQualityAck {
|
||||
if self.operationId.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(self.operationId.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
if self.revision < 1 { return Err(ValidationError::new("revision", "minimum")); }
|
||||
if self.outcome != "applied" && self.outcome != "not_applied" && self.outcome != "uncertain" { return Err(ValidationError::new("outcome", "invalid_value")); }
|
||||
if self.currentAppliedRevision < 0 { return Err(ValidationError::new("current_applied_revision", "minimum")); }
|
||||
if self.leaseGeneration < 1 { return Err(ValidationError::new("lease_generation", "minimum")); }
|
||||
if self.outcome != "applied" && self.outcome != "proven_prior" && self.outcome != "unknown" { return Err(ValidationError::new("outcome", "invalid_value")); }
|
||||
if let Some(value) = &self.currentAppliedRevision {
|
||||
if *value < 0 { return Err(ValidationError::new("current_applied_revision", "minimum")); }
|
||||
}
|
||||
if let Some(value) = &self.failureCode {
|
||||
if !value.is_empty() && value.len() < 1 { return Err(ValidationError::new("failure_code", "min_length")); }
|
||||
if value.len() > 128 { return Err(ValidationError::new("failure_code", "max_length")); }
|
||||
}
|
||||
if self.outcome == "applied" && self.currentAppliedRevision != Some(self.revision) { return Err(ValidationError::new("current_applied_revision", "invalid_tagged_value")); }
|
||||
if self.outcome == "proven_prior" && self.currentAppliedRevision.map_or(true, |current| current >= self.revision) { return Err(ValidationError::new("current_applied_revision", "invalid_tagged_value")); }
|
||||
if self.outcome == "unknown" && self.currentAppliedRevision.is_some() { return Err(ValidationError::new("current_applied_revision", "invalid_tagged_value")); }
|
||||
Ok(())
|
||||
}
|
||||
pub fn version(&self) -> &String { &self.version }
|
||||
@@ -1094,8 +1101,9 @@ impl GatewayQualityAck {
|
||||
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
||||
pub fn operationId(&self) -> &String { &self.operationId }
|
||||
pub fn revision(&self) -> &i64 { &self.revision }
|
||||
pub fn leaseGeneration(&self) -> &i64 { &self.leaseGeneration }
|
||||
pub fn outcome(&self) -> &String { &self.outcome }
|
||||
pub fn currentAppliedRevision(&self) -> &i64 { &self.currentAppliedRevision }
|
||||
pub fn currentAppliedRevision(&self) -> &Option<i64> { &self.currentAppliedRevision }
|
||||
pub fn failureCode(&self) -> &Option<String> { &self.failureCode }
|
||||
}
|
||||
|
||||
@@ -1107,14 +1115,15 @@ pub struct GatewayQualityWork {
|
||||
reconnectSequence: i64,
|
||||
operationId: String,
|
||||
revision: i64,
|
||||
leaseGeneration: i64,
|
||||
leaseExpiresAt: String,
|
||||
selectedDescriptor: SelectedSessionDescriptor,
|
||||
currentAppliedRevision: Option<i64>,
|
||||
}
|
||||
|
||||
impl GatewayQualityWork {
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String, revision: i64, leaseExpiresAt: String, selectedDescriptor: SelectedSessionDescriptor, currentAppliedRevision: Option<i64>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId, revision, leaseExpiresAt, selectedDescriptor, currentAppliedRevision };
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String, revision: i64, leaseGeneration: i64, leaseExpiresAt: String, selectedDescriptor: SelectedSessionDescriptor, currentAppliedRevision: Option<i64>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId, revision, leaseGeneration, leaseExpiresAt, selectedDescriptor, currentAppliedRevision };
|
||||
value.validate()?;
|
||||
Ok(value)
|
||||
}
|
||||
@@ -1132,6 +1141,7 @@ impl GatewayQualityWork {
|
||||
if self.operationId.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(self.operationId.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
if self.revision < 1 { return Err(ValidationError::new("revision", "minimum")); }
|
||||
if self.leaseGeneration < 1 { return Err(ValidationError::new("lease_generation", "minimum")); }
|
||||
if self.leaseExpiresAt.len() > 64 { return Err(ValidationError::new("lease_expires_at", "max_length")); }
|
||||
if !valid_rfc3339_utc(self.leaseExpiresAt.as_str()) { return Err(ValidationError::new("lease_expires_at", "invalid_time")); }
|
||||
self.selectedDescriptor.validate().map_err(|_| ValidationError::new("selected_descriptor", "invalid_object"))?;
|
||||
@@ -1146,6 +1156,7 @@ impl GatewayQualityWork {
|
||||
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
||||
pub fn operationId(&self) -> &String { &self.operationId }
|
||||
pub fn revision(&self) -> &i64 { &self.revision }
|
||||
pub fn leaseGeneration(&self) -> &i64 { &self.leaseGeneration }
|
||||
pub fn leaseExpiresAt(&self) -> &String { &self.leaseExpiresAt }
|
||||
pub fn selectedDescriptor(&self) -> &SelectedSessionDescriptor { &self.selectedDescriptor }
|
||||
pub fn currentAppliedRevision(&self) -> &Option<i64> { &self.currentAppliedRevision }
|
||||
@@ -1157,14 +1168,16 @@ pub struct GatewayQualityWorkRequest {
|
||||
sessionId: String,
|
||||
gatewayId: String,
|
||||
reconnectSequence: i64,
|
||||
operationId: String,
|
||||
revision: i64,
|
||||
acquisition: String,
|
||||
operationId: Option<String>,
|
||||
revision: Option<i64>,
|
||||
leaseGeneration: Option<i64>,
|
||||
currentAppliedRevision: Option<i64>,
|
||||
}
|
||||
|
||||
impl GatewayQualityWorkRequest {
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String, revision: i64, currentAppliedRevision: Option<i64>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId, revision, currentAppliedRevision };
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, acquisition: String, operationId: Option<String>, revision: Option<i64>, leaseGeneration: Option<i64>, currentAppliedRevision: Option<i64>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, acquisition, operationId, revision, leaseGeneration, currentAppliedRevision };
|
||||
value.validate()?;
|
||||
Ok(value)
|
||||
}
|
||||
@@ -1177,22 +1190,34 @@ impl GatewayQualityWorkRequest {
|
||||
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
||||
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
||||
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
||||
if self.operationId.is_empty() { return Err(ValidationError::new("operation_id", "required")); }
|
||||
if !self.operationId.is_empty() && self.operationId.len() < 36 { return Err(ValidationError::new("operation_id", "min_length")); }
|
||||
if self.operationId.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(self.operationId.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
if self.revision < 1 { return Err(ValidationError::new("revision", "minimum")); }
|
||||
if self.acquisition != "poll" && self.acquisition != "prompt" && self.acquisition != "observation" { return Err(ValidationError::new("acquisition", "invalid_value")); }
|
||||
if let Some(value) = &self.operationId {
|
||||
if !value.is_empty() && value.len() < 36 { return Err(ValidationError::new("operation_id", "min_length")); }
|
||||
if value.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(value.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
}
|
||||
if let Some(value) = &self.revision {
|
||||
if *value < 1 { return Err(ValidationError::new("revision", "minimum")); }
|
||||
}
|
||||
if let Some(value) = &self.leaseGeneration {
|
||||
if *value < 1 { return Err(ValidationError::new("lease_generation", "minimum")); }
|
||||
}
|
||||
if let Some(value) = &self.currentAppliedRevision {
|
||||
if *value < 0 { return Err(ValidationError::new("current_applied_revision", "minimum")); }
|
||||
}
|
||||
if self.acquisition == "poll" && (self.operationId.is_some() || self.revision.is_some() || self.leaseGeneration.is_some() || self.currentAppliedRevision.is_some()) { return Err(ValidationError::new("acquisition", "invalid_tagged_value")); }
|
||||
if self.acquisition == "prompt" && (self.operationId.is_none() || self.revision.is_none() || self.leaseGeneration.is_some() || self.currentAppliedRevision.is_some()) { return Err(ValidationError::new("acquisition", "invalid_tagged_value")); }
|
||||
if self.acquisition == "observation" && (self.operationId.is_none() || self.revision.is_none() || self.leaseGeneration.is_none() || self.currentAppliedRevision.is_none()) { return Err(ValidationError::new("acquisition", "invalid_tagged_value")); }
|
||||
Ok(())
|
||||
}
|
||||
pub fn version(&self) -> &String { &self.version }
|
||||
pub fn sessionId(&self) -> &String { &self.sessionId }
|
||||
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
||||
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
||||
pub fn operationId(&self) -> &String { &self.operationId }
|
||||
pub fn revision(&self) -> &i64 { &self.revision }
|
||||
pub fn acquisition(&self) -> &String { &self.acquisition }
|
||||
pub fn operationId(&self) -> &Option<String> { &self.operationId }
|
||||
pub fn revision(&self) -> &Option<i64> { &self.revision }
|
||||
pub fn leaseGeneration(&self) -> &Option<i64> { &self.leaseGeneration }
|
||||
pub fn currentAppliedRevision(&self) -> &Option<i64> { &self.currentAppliedRevision }
|
||||
}
|
||||
|
||||
@@ -1362,12 +1387,13 @@ pub struct GatewayStopWorkRequest {
|
||||
sessionId: String,
|
||||
gatewayId: String,
|
||||
reconnectSequence: i64,
|
||||
operationId: String,
|
||||
acquisition: String,
|
||||
operationId: Option<String>,
|
||||
}
|
||||
|
||||
impl GatewayStopWorkRequest {
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, operationId: String) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, operationId };
|
||||
pub fn new(version: String, sessionId: String, gatewayId: String, reconnectSequence: i64, acquisition: String, operationId: Option<String>) -> Result<Self, ValidationError> {
|
||||
let value = Self { version, sessionId, gatewayId, reconnectSequence, acquisition, operationId };
|
||||
value.validate()?;
|
||||
Ok(value)
|
||||
}
|
||||
@@ -1380,17 +1406,21 @@ impl GatewayStopWorkRequest {
|
||||
if !self.gatewayId.is_empty() && self.gatewayId.len() < 1 { return Err(ValidationError::new("gateway_id", "min_length")); }
|
||||
if self.gatewayId.len() > 128 { return Err(ValidationError::new("gateway_id", "max_length")); }
|
||||
if self.reconnectSequence < 0 { return Err(ValidationError::new("reconnect_sequence", "minimum")); }
|
||||
if self.operationId.is_empty() { return Err(ValidationError::new("operation_id", "required")); }
|
||||
if !self.operationId.is_empty() && self.operationId.len() < 36 { return Err(ValidationError::new("operation_id", "min_length")); }
|
||||
if self.operationId.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(self.operationId.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
if self.acquisition != "poll" && self.acquisition != "prompt" { return Err(ValidationError::new("acquisition", "invalid_value")); }
|
||||
if let Some(value) = &self.operationId {
|
||||
if !value.is_empty() && value.len() < 36 { return Err(ValidationError::new("operation_id", "min_length")); }
|
||||
if value.len() > 36 { return Err(ValidationError::new("operation_id", "max_length")); }
|
||||
if !valid_canonical_uuid(value.as_str()) { return Err(ValidationError::new("operation_id", "invalid_uuid")); }
|
||||
}
|
||||
if self.acquisition == "poll" && self.operationId.is_some() || self.acquisition == "prompt" && self.operationId.is_none() { return Err(ValidationError::new("acquisition", "invalid_tagged_value")); }
|
||||
Ok(())
|
||||
}
|
||||
pub fn version(&self) -> &String { &self.version }
|
||||
pub fn sessionId(&self) -> &String { &self.sessionId }
|
||||
pub fn gatewayId(&self) -> &String { &self.gatewayId }
|
||||
pub fn reconnectSequence(&self) -> &i64 { &self.reconnectSequence }
|
||||
pub fn operationId(&self) -> &String { &self.operationId }
|
||||
pub fn acquisition(&self) -> &String { &self.acquisition }
|
||||
pub fn operationId(&self) -> &Option<String> { &self.operationId }
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
||||
Reference in New Issue
Block a user