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

nsqadmin: add option to skip resolving on startup #1329

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/nsqadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func nsqadminFlagSet(opts *nsqadmin.Options) *flag.FlagSet {
flagSet.Var(&nsqlookupdHTTPAddresses, "lookupd-http-address", "lookupd HTTP address (may be given multiple times)")
nsqdHTTPAddresses := app.StringArray{}
flagSet.Var(&nsqdHTTPAddresses, "nsqd-http-address", "nsqd HTTP address (may be given multiple times)")
flagSet.Bool("skip-resolve-on-startup", false, "skip DNS lookup of addresses on startup")
adminUsers := app.StringArray{}
flagSet.Var(&adminUsers, "admin-user", "admin user (may be given multiple times; if specified, only these users will be able to perform privileged actions; acl-http-header is used to determine the authenticated user)")

Expand Down
20 changes: 11 additions & 9 deletions nsqadmin/nsqadmin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,19 @@ func New(opts *Options) (*NSQAdmin, error) {
n.httpClientTLSConfig.RootCAs = tlsCertPool
}

for _, address := range opts.NSQLookupdHTTPAddresses {
_, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
return nil, fmt.Errorf("failed to resolve --lookupd-http-address (%s) - %s", address, err)
if !opts.SkipResolveOnStartup {
for _, address := range opts.NSQLookupdHTTPAddresses {
_, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
return nil, fmt.Errorf("failed to resolve --lookupd-http-address (%s) - %s", address, err)
}
}
}

for _, address := range opts.NSQDHTTPAddresses {
_, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
return nil, fmt.Errorf("failed to resolve --nsqd-http-address (%s) - %s", address, err)
for _, address := range opts.NSQDHTTPAddresses {
_, err := net.ResolveTCPAddr("tcp", address)
if err != nil {
return nil, fmt.Errorf("failed to resolve --nsqd-http-address (%s) - %s", address, err)
}
}
}

Expand Down
1 change: 1 addition & 0 deletions nsqadmin/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Options struct {

NSQLookupdHTTPAddresses []string `flag:"lookupd-http-address" cfg:"nsqlookupd_http_addresses"`
NSQDHTTPAddresses []string `flag:"nsqd-http-address" cfg:"nsqd_http_addresses"`
SkipResolveOnStartup bool `flag:"skip-resolve-on-startup" cfg:"skip_resolve_on_startup"`

HTTPClientConnectTimeout time.Duration `flag:"http-client-connect-timeout"`
HTTPClientRequestTimeout time.Duration `flag:"http-client-request-timeout"`
Expand Down