-
Notifications
You must be signed in to change notification settings - Fork 493
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
feat: add deduplicate parameter to create topic using cli #4386
Open
fraidev
wants to merge
4
commits into
infinyon:master
Choose a base branch
from
fraidev:dedup_cli
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.dedup { | ||
let deduplication = | ||
create_deduplication(self.setting.dedup_count, Some(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,19 @@ pub struct TopicConfigOpt { | |
#[arg(long, value_name = "bytes")] | ||
max_partition_size: Option<bytesize::ByteSize>, | ||
|
||
/// Deduplicate records in the topic | ||
#[arg(long)] | ||
dedup: bool, | ||
|
||
/// Number of records to keep in deduplication filter | ||
#[arg(long, value_name = "integer", requires = "dedup", 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 = "dedup", default_value = "5s")] | ||
dedup_age: 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be builder pattern so can customize this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that Deduplication, Bounds and Filter implements Builder, but seems a little verbose to create 3 Builders for this, no?
Maybe with additional methods at Deduplication?