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

nsq_to_file: require --topic or --topic-pattern #794

Merged
merged 1 commit into from
Oct 24, 2016

Conversation

judwhite
Copy link
Contributor

@judwhite judwhite commented Oct 4, 2016

fixes #789

Notes:

  • It's a little odd you can specify --topic-pattern without --topic only when using --lookupd-http-address; seems like this should work for --nsqd-tcp-address too.
  • While testing I accidentally ran nsq_to_file --topic [topic1] [topic2] ..., which didn't produce an error, but I wondered why topic2 wasn't getting picked up.
  • Thought (too much) about the if pattern == "" in allowTopicName. I think the alternative is to set it to .* if it's empty once we've determined len(topics) > 0 in main(). I don't have a strong opinion so leaving it to review.

Release notes should indicate people previously using default settings to archive all topics will need to change their command line args.

RFR /cc @mreiferson @jehiah @elubow

@ploxiln
Copy link
Member

ploxiln commented Oct 4, 2016

I think there's a bit of a problem with changing the default topic-pattern without changing this part:

 for _, topic := range topics {
        if !discoverer.allowTopicName(*topicPattern, topic) {
            log.Println("Skipping topic ...")

EDIT: oh I see you've mentioned this explicitly. I guess I also mentally tripped on this a bit. nvm.

👍 for this very minimal behavior fix

@mreiferson
Copy link
Member

It's a little odd you can specify --topic-pattern without --topic only when using --lookupd-http-address; seems like this should work for --nsqd-tcp-address too.

Agreed, would just need to be implemented differently.

While testing I accidentally ran nsq_to_file --topic [topic1] [topic2] ..., which didn't produce an error, but I wondered why topic2 wasn't getting picked up.

That's a Go flag parsing thing and I don't think users expect it to work that way (since it implements pretty typical linux-y style), but I could obviously be wrong.

Thought (too much) about the if pattern == "" in allowTopicName. I think the alternative is to set it to .* if it's empty once we've determined len(topics) > 0 in main(). I don't have a strong opinion so leaving it to review.

If it's confusing let's clean it up?

@judwhite
Copy link
Contributor Author

judwhite commented Oct 5, 2016

If it's confusing let's clean it up?

Do you think it is? I really have no strong opinion, let me know if you want it changed.

@mreiferson
Copy link
Member

mreiferson commented Oct 5, 2016

After looking at it in context, I think both approaches lack obviousness, and I don't have a simple solution. At a high level, I think what makes the most sense is for explicit topics to never go through the discovery code path.

Related, I've always been unhappy with the fact that the topic discovery code is copied in two places.

@judwhite
Copy link
Contributor Author

judwhite commented Oct 5, 2016

Yeah I think my "no strong opinion" stems from the fact I don't like either option 😄 Maybe something closer to right after flag.Parse is called would be more obvious.

I do like the idea of removing the pattern match when explicit topics are set... if you have both --topic and --topic-pattern set we can kick them right out.

@ploxiln
Copy link
Member

ploxiln commented Oct 5, 2016

That's a Go flag parsing thing and I don't think users expect it to work that way (since it implements pretty typical linux-y style)

I don't think it's normal for an unrecognized argument to be silently ignored

(... except for uncommon cases like "true" which don't ever inspect arguments)

@mreiferson
Copy link
Member

I don't think it's normal for an unrecognized argument to be silently ignored

Fair point, it probably would make sense for it to error. From the docs:

Flag parsing stops just before the first non-flag argument ("-" is a non-flag argument) or after the terminator "--".

@mreiferson
Copy link
Member

I guess it considers those "arguments"?

@mreiferson
Copy link
Member

is this ready to go?

@judwhite
Copy link
Contributor Author

@mreiferson for the initial request it is. if we want to do the rest of the suggestions discussed we can wait, and make the code a little better. been busy but things should settle shortly.

@mreiferson
Copy link
Member

@judwhite if this addresses the original issue, let's land it, and we can follow up with cleanup if we have the time.

@mreiferson mreiferson merged commit ad89e8c into nsqio:master Oct 24, 2016
@judwhite judwhite mentioned this pull request Oct 26, 2016
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nsq_to_file: could use some saner defaults
3 participants