Skip to content

Commit

Permalink
Use version instead of sequence for commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Bruijnzeels committed Jul 5, 2023
1 parent b65f12b commit f45c704
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions src/commons/api/history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl CommandHistory {

impl fmt::Display for CommandHistory {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "time::command::sequence::success")?;
writeln!(f, "time::command::version::success")?;

for command in self.commands() {
let success_string = match &command.effect {
Expand All @@ -68,7 +68,7 @@ impl fmt::Display for CommandHistory {
};
writeln!(
f,
"{}::{} ::{}::{}",
"{}::{}::{}::{}",
command.time().to_rfc3339_opts(SecondsFormat::Secs, true),
command.summary.msg,
command.version,
Expand Down Expand Up @@ -98,7 +98,7 @@ pub struct CommandHistoryRecord {
impl CommandHistoryRecord {
pub fn matches(&self, crit: &CommandHistoryCriteria) -> bool {
crit.matches_timestamp_secs(self.timestamp)
&& crit.matches_sequence(self.version)
&& crit.matches_version(self.version)
&& crit.matches_label(&self.summary.label)
}
}
Expand Down Expand Up @@ -224,7 +224,7 @@ pub struct CommandHistoryCriteria {
#[serde(skip_serializing_if = "Option::is_none")]
after: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
after_sequence: Option<u64>,
after_version: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
label_includes: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -252,8 +252,8 @@ impl CommandHistoryCriteria {
self.before = Some(timestamp);
}

pub fn set_after_sequence(&mut self, sequence: u64) {
self.after_sequence = Some(sequence)
pub fn set_after_version(&mut self, version: u64) {
self.after_version = Some(version)
}

pub fn set_rows(&mut self, rows: usize) {
Expand Down Expand Up @@ -282,10 +282,10 @@ impl CommandHistoryCriteria {
true
}

pub fn matches_sequence(&self, sequence: u64) -> bool {
match self.after_sequence {
pub fn matches_version(&self, version: u64) -> bool {
match self.after_version {
None => true,
Some(seq_crit) => sequence > seq_crit,
Some(seq_crit) => version > seq_crit,
}
}

Expand Down Expand Up @@ -319,7 +319,7 @@ impl Default for CommandHistoryCriteria {
CommandHistoryCriteria {
before: None,
after: None,
after_sequence: None,
after_version: None,
label_includes: None,
label_excludes: None,
offset: 0,
Expand Down
10 changes: 5 additions & 5 deletions src/commons/eventsourcing/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,10 +552,10 @@ where
)
}

fn key_for_command(agg: &MyHandle, sequence: u64) -> Key {
fn key_for_command(agg: &MyHandle, version: u64) -> Key {
Key::new_scoped(
Scope::from_segment(Segment::parse_lossy(agg.as_str())), // agg should always be a valid Segment
Segment::parse(&format!("command-{}.json", sequence)).unwrap(), // cannot panic as a u64 cannot contain a Scope::SEPARATOR
Segment::parse(&format!("command-{}.json", version)).unwrap(), // cannot panic as a u64 cannot contain a Scope::SEPARATOR
)
}

Expand Down Expand Up @@ -789,10 +789,10 @@ impl fmt::Display for AggregateStoreError {
AggregateStoreError::ConcurrentModification(handle) => {
write!(f, "concurrent modification attempt for entity: '{}'", handle)
}
AggregateStoreError::UnknownCommand(handle, seq) => write!(
AggregateStoreError::UnknownCommand(handle, version) => write!(
f,
"Aggregate '{}' does not have command with sequence '{}'",
handle, seq
"Aggregate '{}' does not have command with version '{}'",
handle, version
),
AggregateStoreError::WarmupFailed(handle, e) => {
write!(f, "Could not rebuild state for '{}': {}", handle, e)
Expand Down
4 changes: 2 additions & 2 deletions src/daemon/ca/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ impl CaManager {
}

/// Shows the details for a CA command.
pub fn ca_command_details(&self, handle: &CaHandle, sequence: u64) -> KrillResult<CaCommandDetails> {
pub fn ca_command_details(&self, handle: &CaHandle, version: u64) -> KrillResult<CaCommandDetails> {
self.ca_store
.get_command(handle, sequence)
.get_command(handle, version)
.map_err(Error::AggregateStoreError)
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/daemon/krillserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -846,8 +846,8 @@ impl KrillServer {
self.ca_manager.ca_history(ca, crit).await
}

pub fn ca_command_details(&self, ca: &CaHandle, sequence: u64) -> KrillResult<CaCommandDetails> {
self.ca_manager.ca_command_details(ca, sequence)
pub fn ca_command_details(&self, ca: &CaHandle, version: u64) -> KrillResult<CaCommandDetails> {
self.ca_manager.ca_command_details(ca, version)
}

/// Returns the publisher request for a CA, or NONE of the CA cannot be found.
Expand Down

0 comments on commit f45c704

Please sign in to comment.