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

out_file/out_secondary_file: Support ${chunk_id} placeholder. fix #1705 #1708

Merged
merged 3 commits into from
Oct 13, 2017

Conversation

repeatedly
Copy link
Member

${chunk_id} placeholder is useful for out_file like plugins.
So I added CHUNK_ID_PLACEHOLDER_PATTERN in Output to share.
For example, out_webhdfs uses own ${chunk_id} value but it should use this predefined constant.

@@ -178,7 +178,7 @@ def format(tag, time, record)
end

def write(chunk)
path = extract_placeholders(@path_template, chunk.metadata)
path = extract_placeholders(@path_template.gsub(CHUNK_ID_PLACEHOLDER_PATTERN, dump_unique_id_hex(chunk.unique_id)), chunk.metadata)
Copy link
Member

@mururu mururu Oct 4, 2017

Choose a reason for hiding this comment

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

It seems better if the replacements of CHUNK_ID_PLACEHOLDER_PATTERN is done by extract_placeholders instead of each plugins. For now, only these two plugins use this method, but it is useful if all plugins can use this feature automatically in the future.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it is one idea.
For it, we need to change extract_placeholders API.

  1. 2nd argument changed to chunk, not chunk.metadata

For compatibility, we need to check 2nd argument type.

metadata = chunk.metadata if metadata.is_a?(Chunk)
  1. Add 3rd argument for chunk

def extract_placeholders(str, metadata, chunk = nil)

metadata is from chunk so this API is a little strange.

  1. Add 3rd argument for additional params

This avoids further API changes.

def extract_placeholders(str, metadata, extras = nil)
  if extras && extras.has_key?(:chunk)
  end
end

I think 1 is better because this doesn't break exsiting API and doesn't add more argument.
We can change Plugin API before stable announcement.

Copy link
Member

Choose a reason for hiding this comment

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

👍 > 1

Copy link
Contributor

@cosmo0920 cosmo0920 Oct 6, 2017

Choose a reason for hiding this comment

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

I agree to change extract_placeholders API.
👍 > 1 and 3. Both of them look good to me.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 > 1

@repeatedly
Copy link
Member Author

@okkez @cosmo0920 How about above change? Do you have other opinion?

@repeatedly
Copy link
Member Author

Change extract_placeholders API. PTAL!

@repeatedly repeatedly merged commit f2736ac into master Oct 13, 2017
@repeatedly repeatedly deleted the chunk_id-placeholder branch November 14, 2017 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants