-
Notifications
You must be signed in to change notification settings - Fork 493
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add deduplicate opt for create topic cli
- Loading branch information
Showing
6 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,18 @@ use fluvio_sc_schema::shared::validate_resource_name; | |
use fluvio_sc_schema::mirror::MirrorSpec; | ||
use fluvio_sc_schema::topic::HomeMirrorConfig; | ||
use fluvio_sc_schema::topic::MirrorConfig; | ||
use fluvio_sc_schema::topic::Bounds; | ||
use fluvio_sc_schema::topic::Deduplication; | ||
use fluvio_sc_schema::topic::Filter; | ||
use fluvio_sc_schema::topic::Transform; | ||
|
||
use fluvio::Fluvio; | ||
use fluvio::FluvioAdmin; | ||
use fluvio::metadata::topic::TopicSpec; | ||
use crate::CliError; | ||
|
||
const DEFAULT_DEDUP_FILTER: &str = "fluvio/[email protected]"; | ||
|
||
#[derive(Debug, Parser)] | ||
pub struct CreateTopicOpt { | ||
/// The name of the Topic to create | ||
|
@@ -229,6 +235,12 @@ impl CreateTopicOpt { | |
topic_spec.set_compression_type(compression_type); | ||
} | ||
|
||
if self.setting.deduplicate { | ||
let deduplication = | ||
create_deduplication(self.setting.dedup_count, self.setting.dedup_age); | ||
topic_spec.set_deduplication(Some(deduplication)); | ||
} | ||
|
||
topic_spec.set_system(self.setting.system); | ||
|
||
if self.setting.segment_size.is_some() || self.setting.max_partition_size.is_some() { | ||
|
@@ -258,6 +270,21 @@ fn validate(name: &str, _spec: &TopicSpec) -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
fn create_deduplication(dedup_count: u64, dedup_age: Option<Duration>) -> Deduplication { | ||
Deduplication { | ||
bounds: Bounds { | ||
count: dedup_count, | ||
age: dedup_age, | ||
}, | ||
filter: Filter { | ||
transform: Transform { | ||
uses: DEFAULT_DEDUP_FILTER.to_string(), | ||
with: Default::default(), | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
#[derive(Debug, Parser)] | ||
#[group(id = "config-arg")] | ||
pub struct TopicConfigOpt { | ||
|
@@ -280,6 +307,24 @@ pub struct TopicConfigOpt { | |
#[arg(long, value_name = "bytes")] | ||
max_partition_size: Option<bytesize::ByteSize>, | ||
|
||
/// Deduplicate records in the topic | ||
#[arg(long)] | ||
deduplicate: bool, | ||
|
||
/// Number of records to keep in deduplication filter | ||
#[arg( | ||
long, | ||
value_name = "integer", | ||
requires = "deduplicate", | ||
default_value = "5" | ||
)] | ||
dedup_count: u64, | ||
|
||
/// Age of records to keep in deduplication filter | ||
/// Ex: '1h', '2d 10s', '7 days' (default) | ||
#[arg(long, value_name = "time", value_parser=parse_duration, requires = "deduplicate")] | ||
dedup_age: Option<Duration>, | ||
|
||
/// Flag to create a system topic | ||
/// System topics are for internal operations | ||
#[arg(long, short = 's', hide = true)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "fluvio-controlplane-metadata" | ||
edition = "2021" | ||
version = "0.30.1" | ||
version = "0.30.2" | ||
authors = ["Fluvio Contributors <[email protected]>"] | ||
description = "Metadata definition for Fluvio control plane" | ||
repository = "https://github.com/infinyon/fluvio" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +236,7 @@ deduplication: | |
age: 1m | ||
filter: | ||
transform: | ||
uses: infinyon/[email protected] | ||
uses: fluvio/dedup-bloom[email protected] | ||
"#; | ||
|
||
//when | ||
|
@@ -373,7 +373,7 @@ compression: | |
}, | ||
filter: Filter { | ||
transform: Transform { | ||
uses: "infinyon/[email protected]".to_string(), | ||
uses: "fluvio/dedup-bloom[email protected]".to_string(), | ||
with: Default::default(), | ||
}, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters