Skip to content

feat: add task type to ID generation for Standard and PersistentCache tasks #1149

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

Merged
merged 1 commit into from
May 14, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions dragonfly-client-util/src/id_generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ impl IDGenerator {
hasher.update(piece_length.to_string());
}

hasher.update(TaskType::Standard.as_str_name().as_bytes());

// Generate the task id.
Ok(hex::encode(hasher.finalize()))
}
Expand Down Expand Up @@ -206,6 +208,8 @@ impl IDGenerator {
hasher.update(piece_length.to_string().as_bytes());
}

hasher.update(TaskType::PersistentCache.as_str_name().as_bytes());

// Generate the task id by crc32.
Ok(hasher.finalize().to_string())
}
Expand Down Expand Up @@ -277,7 +281,7 @@ mod tests {
application: Some("bar".to_string()),
filtered_query_params: vec![],
},
"99a47b38e9d3321aebebd715bea0483c1400cef2f767f84d97458f9dcedff221",
"27554d06dfc788c2c2c60e01960152ffbd4b145fc103fcb80b432b4dc238a6fe",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -288,7 +292,7 @@ mod tests {
application: Some("bar".to_string()),
filtered_query_params: vec![],
},
"160fa7f001d9d2e893130894fbb60a5fb006e1d61bff82955f2946582bc9de1d",
"06408fbf247ddaca478f8cb9565fe5591c28efd0994b8fea80a6a87d3203c5ca",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -299,7 +303,7 @@ mod tests {
application: None,
filtered_query_params: vec![],
},
"2773851c628744fb7933003195db436ce397c1722920696c4274ff804d86920b",
"3c3f230ef9f191dd2821510346a7bc138e4894bee9aee184ba250a3040701d2a",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -310,7 +314,7 @@ mod tests {
application: Some("bar".to_string()),
filtered_query_params: vec![],
},
"63dee2822037636b0109876b58e95692233840753a882afa69b9b5ee82a6c57d",
"c9f9261b7305c24371244f9f149f5d4589ed601348fdf22d7f6f4b10658fdba2",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -321,7 +325,7 @@ mod tests {
application: None,
filtered_query_params: vec![],
},
"40c21de3ad2f1470ca1a19a2ad2577803a1829851f6cf862ffa2d4577ae51d38",
"9f7c9aafbc6f30f8f41a96ca77eeae80c5b60964b3034b0ee43ccf7b2f9e52b8",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -332,7 +336,7 @@ mod tests {
application: None,
filtered_query_params: vec!["foo".to_string(), "bar".to_string()],
},
"100680ad546ce6a577f42f52df33b4cfdca756859e664b8d7de329b150d09ce9",
"457b4328cde278e422c9e243f7bfd1e97f511fec43a80f535cf6b0ef6b086776",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand Down Expand Up @@ -363,7 +367,7 @@ mod tests {
tag: Some("tag1".to_string()),
application: Some("app1".to_string()),
},
"223755482",
"3490958009",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -373,7 +377,7 @@ mod tests {
tag: None,
application: Some("app1".to_string()),
},
"1152081721",
"735741469",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -383,7 +387,7 @@ mod tests {
tag: Some("tag1".to_string()),
application: None,
},
"990623045",
"3954905097",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand All @@ -393,7 +397,7 @@ mod tests {
tag: None,
application: None,
},
"1293485139",
"4162557545",
),
(
IDGenerator::new("127.0.0.1".to_string(), "localhost".to_string(), false),
Expand Down
Loading