Skip to content
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

Validators for buffering key extraction #1255

Merged
merged 2 commits into from
Oct 5, 2016

Conversation

tagomoris
Copy link
Member

@tagomoris tagomoris commented Oct 4, 2016

This change is mainly to make plugin authors possible to check configuration values are valid or not in the viewpoint of placeholders, like ${tag}, %Y-%m-%d or ${any_key}s.

Users can write any placeholders in their configuration parameters if plugin author provides a feature to extract it with buffer chunk keys. But buffer chunk keys and placeholders used in these values MUST be consistent. This consistency is very easy to be broken.

Newly introduced methods provides features to validate these parameters and buffering configurations.

This change is based on #1254.

@tagomoris tagomoris added enhancement Feature request or improve operations v0.14 labels Oct 4, 2016
validators
end

class PlaceholderValidator
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think separating PlaceholderValidator into TagPlaceholderValidator, TimePlaceholderValidator, KeysPlaceholderValidator is better.
It removes time?, tag? and keys? helpers and reduces method call overhead in validate!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it doesn't work. We should provide the possibility to plugin authors, for selecting which validator should be called or not.
For example, table might not have timestamp placeholders even when time chunk key is configured for any databases which can handle automatically generated time partitions. In such cases, the validator for time can be skipped by plugin authors (by using validator.time?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.

def get_placeholders_tag(str)
# [["tag"],["tag[0]"]]
parts = []
str.scan(/\$\{(tag(?:\[\d+\])?)\}/).map(&:first).each do |ph|
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use constant value to share regexp.
extract_placeholders also uses same regexp.

@tagomoris
Copy link
Member Author

I added a commit for tag placeholder.

@tagomoris tagomoris force-pushed the validators-for-buffering-key-extraction branch from c3f4260 to 9eb470e Compare October 5, 2016 06:39
@tagomoris
Copy link
Member Author

I rebased on current master and added a commit for regexp.
@repeatedly ping?

@repeatedly
Copy link
Member

It seems good.

@tagomoris tagomoris merged commit 2713642 into master Oct 5, 2016
@tagomoris tagomoris deleted the validators-for-buffering-key-extraction branch October 5, 2016 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations v0.14
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants